Created
May 12, 2016 12:25
-
-
Save lfreeland/e9bef06713b0378d5a95ad1390863215 to your computer and use it in GitHub Desktop.
Upsert List<SObject> with External Id with "AllOrNothing" Error Example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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