Salesforce
PDII · Question #257
Refer to the code snippet below: As part of an integration development effort, a developer is tasked to create an Apex method that solely relies on the use of foreign identifiers in order to relate…
The correct answer is D. Account parentAccount = new Account(). See the full explanation below for the reasoning.
Question
Refer to the code snippet below:
As part of an integration development effort, a developer is tasked to create an Apex method that solely relies on the use of foreign identifiers in order to relate new contact records to existing Accounts in Salesforce. The account object contains a field marked as an external ID, the API Name of this field is Legacy_Id_c. What is the most efficient way to instantiate the parentAccount variable on line 02 to ensure the newly created contact is properly related to the Account?
Exhibit
Options
- AAccount parentAccount = new Account(Legacy_Id_c = externalIdentifier);
- BAccount parentAccount = [SELECT Id FROM Account WHERE Legacy_Id_c
- CAccount parentAccount = [SELECT Id FROM Account WHERE Legacy_Id_c = :externalIdentifier];
- DAccount parentAccount = new Account();
How the community answered
(55 responses)- A9% (5)
- B16% (9)
- C4% (2)
- D71% (39)
Community Discussion
No community discussion yet for this question.
