I have looked at the documentation on Database Methods. What I do not understand is, what happens when an upsert is performed without specifying an external id field? Is it just based on whether or not the record has an Id?


1 Answer 1


It just simply check if ID field is set then SFDC update the record orther wise it just insert record.

for ex:

List<Account> al = new list<Account>();

Account a1 = new account(ID='0019000001dK6Rd', Name='XXXX Test Account 1'); 
al.add(a1); // This is updated as ID is passed 

Account a2 = new account(MyExtID__c='Target#001', Name='XXXX Test Account 2'); 
al.add(a2);// This is updated as External ID is passed

Account a3 = new account( Name='XXXX Test Account 3'); 
al.add(a3);// This is inserted as both ID & External ID is NOT passed



Upsert is a merging of the words insert and update. This call is available for objects if the object has an external ID field or a field with the idLookup field property.


  • Do you have any documentation to back this statement up? It was my assumption from the start, but I couldn't find any supporting materials.
    – Adrian Larson
    Feb 10, 2016 at 15:25
  • This is not an assumption. You can run the code and verify it with appropriate data. Also added link of documentation. Feb 11, 2016 at 4:46
  • It is not the correctness of your answer that I am unsure of, but its completeness. Does the system only consider the Id field if no external field is specified?
    – Adrian Larson
    Feb 12, 2016 at 23:40
  • Yes, There are only 2 ways record can be uniquely identify. one is ID and second is unique external id. Feb 22, 2016 at 4:02

You must log in to answer this question.

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