How To Reference the External ID on Lookup in Salesforce

This post shows you how you can reference another object through it’s external id AV????? ?????????RICOH? ???? SP EC???6100H . This is useful if you do not know the Salesforce ID but know the external ID.

Example: You have an external field on the Account object with an API named myExternal_Id__c ???????????? ??G3030T ?JAN4975846033405 aso1-8737-06 -??????? . You have an account record named “Burlington Textile of America” and let’s give the external ID a value of “X123”.


Issue is you want to create a contact record but do not know the account record id but know the external Id.

Check this snippet of apex code to accomplish this.

Account acc = new Account(myExternal_Id__c = ‘X123’);

Contact con = new Contact();

con.Account = acc;

con.LastName = ‘Pau’;

insert con;

The same concept is applicable for JSON files


“Account” : {“myExternal_Id__c” : “X123”},

“LastName” : “Pau”



Post Author: lopau

Leave a Reply

Your email address will not be published. Required fields are marked *