user1445203
user1445203

Reputation: 61

How to update a nested sobject using simple_salesforce?

I have been trying to update a nested object using simple_salesforce specifically been trying to update the Owner field in a Case object.

from simple_salesforce import Salesforce
sf = Salesforce(username = 'username',password = 'password',security_token='security_token', sandbox = False)

sf.Case.create({'Description':'stuff in description','Owner':'Owners User'})

Whenever I try to insert I get the following error:

Response content:

[{u'errorCode': u'INVALID_FIELD', u'message': u'The value provided for foreign key reference Owner is not a nested SObject'}]

Please any help would be appreciated.

Upvotes: 6

Views: 2122

Answers (2)

Mudbob
Mudbob

Reputation: 1

I had the same issue with setting the Opportunity RecordType - I was trying to use the "text" of the Type name. However, you have to pass the 15 digit SF name of the Record Type, to find that, you need to go to SETUP, Opportunities, RecordTypes, click Edit by your record type, and in the URL you will see a the value:

https://----------.cs44.my.salesforce.com/setup/ui/recordtypefields.jsp?id=01215000001UUtL&type=Opportunity&setupid=OpportunityRecords

The value you pass in the above example is: '01215000001UUtL'

Your Simple-Salesforce Call would look like:

sf.opportunity.create({'RecordTypeId':"01215000001UUtL",'AccountId':SFaccountId,'CloseDate':SFcloseDate,'StageName':'Closed Won','Name':'OPPORTUNITY NAME'})

Upvotes: 0

nomadic_squirrel
nomadic_squirrel

Reputation: 644

I ran into this same error and it turns out you have to use the OwnerId field and pass the Id of the owner.

Upvotes: 4

Related Questions