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
It just simply check if ID field is set then SFDC update the record orther wise it just insert record.
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 Database.upsert(al);
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.