0

我需要更新一些salesforce对象的自定义字段。为此,我正在尝试使用该upsert方法。我对选择模块有点困惑;SforceEnterpriseClientSforcePartnerClientsforce。我想我需要第一个的package prefix名字upsertsforce我需要使用or来做这些事情suds。关于sforcesuds技巧的一点解释会很有帮助。

4

1 回答 1

1

你试过beatbox库吗?它比 salesforce-python-toolkit 更简单

这是如何更新自定义字段的完整示例:

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()
于 2012-09-20T15:44:26.083 回答