0

Scenario We have an integration that upserts records against Sobject A, C and CO. (I'm using letters to represent for brevity) A - Account C - Contact CO - CustomSobject (junction Sobject between A & C, similar to AccountContactRelation)

Sobject A has an external Id. The external Id is used as the external system is the master of the data and they have no understanding of SFIds. You're going to see a lot of External Ids here.

Sobject C also has an external Id. As a Contact it also looks up to the Account (these are customer Contacts). The lookup to the Account in Salesforce from C is populated by reference to the External Id field on the Account.

Sobject CO has an external Id as well. As it is a junction Sobject between A and C it needs to ensure that those lookups are populated correctly. External Ids for both Account and Contact are used to populate those lookup(both are M-D relationships) fields too.

Integration is using SOAP API.

Integration is on a timer, which performs 3 jobs. 1st job is Account. 2nd job is Contact. 3rd job is CustomSobject. All jobs are upserts using the External Id as the key.

The Issue Most entries in the results table in the system that is integrating into Salesforce is finding that the Contact is encountering multiple types of errors that we're having trouble debugging. Occasionally, Contacts insert correctly this is the exception and not the rule.

Account typically upsert no problem.

Contacts typically fail with an error

  • Could not create a duplicate ExternalId__c field. (running user has access to field)

Custom Sobject typically fails with one of two errors.

  • Bad Field Name on Contact ExternalId__c (perhaps happening if a Contact does exist, but not allowed the reference the field)
  • Could not find Contact for external Id ExternalId__c. (Matches when the Contact sync fails on the previous job in the transaction).

All of this is pointing to the Contact.ExternalId__c field being hidden from the User/Profile that's running the job.

Testing Steps Taken However I've created another User with the same Profile and Permission Set assignments and have created a small test in Postman using the Composite REST API.

I can upsert Contacts CustomSobjects no problem using this User and am not seeing issues syncing any of the Sobject listed here.

The only variance I'm seeing right now between the real world scenario and my test scenario, is the integration method

  • Testing: REST/Composite
  • Real World: SOAP API, transaction size.

Any guidance at all on next steps? Definitely hitting my head against the wall a little here.

  • From Contact error, it looks like you are trying to create contact with an externalid__c which is not unique and this field must be unique at field definition level. Can you check if the contact already exists with the failed externalid__c? – Manish Anand Apr 29 at 4:45
  • Hi @ManishAnand, this issue shouldn't be happening because we're upserting using that ExternalId as the key, so it should be finding and updating the existing record rather than creating a new one. – JetSparx Apr 29 at 16:58
  • It will be good if you can paste the code as well, to look into it further. – Manish Anand Apr 29 at 17:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.