Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save lfreeland/e9bef06713b0378d5a95ad1390863215 to your computer and use it in GitHub Desktop.

Select an option

Save lfreeland/e9bef06713b0378d5a95ad1390863215 to your computer and use it in GitHub Desktop.
Upsert List<SObject> with External Id with "AllOrNothing" Error Example
public static List<Database.UpsertResult> upsertListSObjectsWithExternalIdWithAllOrNothingErrorExample() {
List<SObject> records = new List<SObject>();
Account a = new Account(
Name = 'Example Company',
External_Id__c = 'ExampleCompany'
);
records.add(a);
Schema.SObjectField f = Account.Fields.External_Id__c;
/* this throws a compilation error of
* Compile Error: Upsert requires a concrete SObject type at line ## column ##
*/
return Database.Upsert(records, f, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment