1

I'm trying to create a Contact trough a REST API. I want it to be linked with an Account. At this point I don't know the AccountId, however, I do know a value of ext_id__c which is a custom field marked as External ID.

Associating objects with external IDs works fine for custom relationships. It's documented here: https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm I can't figure out how to achieve the same for the build-in relationship between Contact and Account. I have tried several approaches:

  • AccountId: "<ext_id>"
  • AccountId: { ext_id__c: "<ext_id>" }
  • AccountId__r: { ext_id__c: "<ext_id>" }
  • AccountId.ext_id__c: "<ext_id>"
  • AccountId_ext_id__c: "<ext_id>"
  • AccountId: "ext_id__c/<ext_id>"

All attempts failed with an error complaining about malformed id or no such column.

2 Answers 2

3

I've finally figured it out. When you want to associate a Contact with an Account using an external ID than it should be passed in this way:

Account: { ext_id__c: "<ext_id>" }
2
  • I'm facing the same issue, for me it's not working this formate "Account: { ext_id__c: "<ext_id>" }" Could you please post your entire JSON and REST URL Mar 23, 2020 at 12:34
  • @Nishadkallingal Unfortunately, I have no longer access to the code. Mar 23, 2020 at 19:37
0

you need to do do it like this:

{ ... "account": { "yourexternalid":"value" }, ... }

only for the case the you're going to relate a custom object you'd need to use the custom objects name instead. Due to that you're going to a related attribute of account you're using "account" instead of "accountid", like you're doing it in relationship queries.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .