简体   繁体   English

Python beatbox salesforce外部Id upsert

[英]Python beatbox salesforce external Id upsert

I'm trying to upsert a record via the salesforce Beatbox python client the upsert operation seems to work fine but I can't quite work out how to specify an externalid as a foreign key: 我试图通过salesforce Beatbox python客户端来记录一个记录,upsert操作似乎工作正常,但我不能完全弄清楚如何将externalid指定为外键:

Attempting to upsert with: 尝试使用:upsert:

consolidatedToInsert = []

for id,ce in ConsolidatedEbills.items():
    consolidatedToInsert.append(
        {
            'type':'consolidated_ebill__c',
            'Account__r':{'type':'Account','ETL_Natural_Key__c':ce['CLASS_REFERENCE']},
            'ETL_Natural_Key__c':ce['ISSUE_UNIQUE_ID']
        }
    )

print consolidatedToInsert[0]

pc.login('USERNAME', 'TOTALLYREALPASSWORD')
ret = pc.upsert('ETL_Natural_Key__c',consolidatedToInsert[0])
print ret

gives the error: 给出错误:

'The external foreign key reference does not reference a valid entity: Account__r' '外部外键引用不引用有效实体:Account__r'

[{'isCreated': False, 'errors': [{'fields': [], 'message': 'The external foreign key reference does not reference a valid entity: Account__r', 'statusCode': 'INVALID_FIEL D'}], 'id': '', 'success': False, 'created': False}] [{'isCreated':False,'errors':[{'fields':[],'message':'外部外键引用不引用有效实体:Account__r','statusCode':'INVALID_FIEL D'} ],'id':'','成功':错误,'创建':False}]

The soap examples and the specificity of the error text seem to indicate that it's possible but I can find little in the documentation about inserting with external ids. 肥皂的例子和错误文本的特殊性似乎表明它是可能的,但我在文档中找不到有关插入外部ID的信息。


On a closer look I'm not sure if this is possible at all, a totally mangled key to Account__r seems to pass silently as if it's not even being targeted for XML translation, I'd love to be wrong though. 仔细看看我不确定这是否可能,Account__r的一个完全错误的键似乎默默地传递,好像它甚至不是XML翻译的目标,但我喜欢错。


A quick change to pythonclient.py 422:0: 快速更改pythonclient.py 422:0:

     for k,v in field_dict.items():
         if v is None:
             fieldsToNull.append(k)
             field_dict[k] = []
         if k.endswith('__r') and isinstance(v,dict):
             pass
         elif hasattr(v,'__iter__'):
             if len(v) == 0:
                 fieldsToNull.append(k)
             else:
                 field_dict[k] = ";".join(v)

and another to __beatbox.py 375:0 另一个是__beatbox.py 375:0

        for fn in sObjects.keys():
            if (fn != 'type'):
                if (isinstance(sObjects[fn],dict)):
                    self.writeSObjects(s, sObjects[fn], fn)
                else:
                    s.writeStringElement(_sobjectNs, fn, sObjects[fn])

and it works like some dark magic. 它就像一些黑暗魔法。

Currently Beatbox doesn't support serializing nested dictionaries like this, which is needed for the externalId resolution you're trying to do. 目前,Beatbox不支持序列化这样的嵌套字典,这是您尝试执行的externalId解析所需要的。 (If you look at the generated request, you can see that the nested dictionary is just serialized as a string)). (如果查看生成的请求,可以看到嵌套字典只是序列化为字符串))。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM