Salesforce Platform Developer I (legacy) — Question 115
A developer needs to save a List of existing Account records named myAccounts to the database, but the records do not contain Salesforce Id values. Only the value of a custom text field configured as an External ID with an API name of Foreign_Key__c is known.
Which two statements enable the developer to save the records to the database without an Id? (Choose two.)
Answer options
- A. Upsert myAccounts Foreign_Key__c;
- B. Upsert myAccounts(Foreign_Key__c);
- C. Database.upsert (myAccounts, Foreign_Key__c);
- D. Database.upsert(myAccounts).Foreign_Key__c;
Correct answer: A, C
Explanation
Option A is correct because it uses the upsert statement correctly with the External ID. Option C is also correct as it employs Database.upsert with the correct parameters for the External ID. Options B and D are incorrect because they do not follow the correct syntax for upserting records using External IDs.