Welcome to ExamTopics
ExamTopics Logo
- Expert Verified, Online, Free.
exam questions

Exam Certified Platform Developer II All Questions

View all questions & answers for the Certified Platform Developer II exam

Exam Certified Platform Developer II topic 1 question 276 discussion

Actual exam question from Salesforce's Certified Platform Developer II
Question #: 276
Topic #: 1
[All Certified Platform Developer II Questions]

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?

  • A. Account parentAccount = new Account(Legacy_Id_c = externalIdentifier);
  • B. Account parentAccount = [SELECT Id FROM Account WHERE Legacy_Id_c = :externalIdentifier].Id;
  • C. Account parentAccount = [SELECT Id FROM Account WHERE Legacy_Id_c = :externalIdentifier];
  • D. Account parentAccount = new Account();
    parentAccount.Id = externalIdentifier;
Show Suggested Answer Hide Answer
Suggested Answer: A 🗳️

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
BrucePark
Highly Voted 1 year, 2 months ago
Selected Answer: A
This is A. I tested it.
upvoted 5 times
M4JK3LSON
10 months, 3 weeks ago
A creates new Account instance but question iclude information, that we use scope of EXISITNG ACCOUNTS
upvoted 1 times
...
...
true_dev
Most Recent 1 month ago
A. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_dml_nested_object.htm
upvoted 1 times
...
FriedConsole2000
8 months, 2 weeks ago
Selected Answer: C
It is C
upvoted 1 times
...
Sapphire808
1 year, 1 month ago
Selected Answer: C
C. Both A and D create a new parent account, which is not needed since the account is already in the system as stated by the question. Therefore that leaves B and C. It cannot be B because that does not follow proper formatting and assignment rules, plus the Id is already indicated as the field to get from the SOQL query. That means the answer is C.
upvoted 1 times
...
[Removed]
1 year, 2 months ago
Selected Answer: C
We can search for an existing Account using an external ID and retrieve its Account object. C is the most efficient approach. By setting this object in the newContact.Account field, the new contact will be correctly associated with the Account.
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...