我需要更新salesforce
个对象的一些自定义字段。为此,我尝试使用upsert
方法。我对选择模块感到困惑; SforceEnterpriseClient
的{{1}}或SforcePartnerClient
。我想我首先需要sforce
的名称package prefix
。我需要使用upsert
或sforce
执行这些操作。对suds
和sforce
技巧的一点解释会有所帮助。
答案 0 :(得分:1)
你试过beatbox图书馆吗?它比salesforce-python-toolkit
简单This is a full sample如何设置自定义字段:
import sys
import beatbox
import xmltramp
import datetime
sf = beatbox._tPartnerNS
svc = beatbox.Client()
class BeatBoxDemo:
def login(self, username, password):
self.password = password
loginResult = svc.login(username, password)
print "sid = " + str(loginResult[sf.sessionId])
print "welcome " + str(loginResult[sf.userInfo][sf.userFullName])
def upsert(self):
print "\nupsert"
t = { 'type': 'Task',
'ChandlerId__c': '12345',
'subject': 'BeatBoxTest updated',
'ActivityDate' : datetime.date(2006,2,20) }
ur = svc.upsert('ChandlerId__c', t)
print str(ur[sf.success]) + " -> " + str(ur[sf.id])
t = { 'type': 'Event',
'ChandlerId__c': '67890',
'durationinminutes': 45,
'subject': 'BeatBoxTest',
'ActivityDateTime' : datetime.datetime(2006,2,20,13,30,30),
'IsPrivate': False }
ur = svc.upsert('ChandlerId__c', t)
if str(ur[sf.success]) == 'true':
print "id " + str(ur[sf.id])
else:
print "error " + str(ur[sf.errors][sf.statusCode]) + ":" + str(ur[sf.errors][sf.message])
if __name__ == "__main__":
if len(sys.argv) != 3:
print "usage is demo.py <username> <password>"
else:
demo = BeatBoxDemo()
demo.login(sys.argv[1], sys.argv[2])
demo.upsert()