Exam Plat-Dev-301 Topic 1 Question 52 Discussion
Actual exam question for Salesforce's Plat-Dev-301 exam
Question #: 52
Topic #: 1
Question #: 52
Topic #: 1
A developer created an Apex class that updates an Account based on input from a Lightning web component that Is used to register an Account. The update to the Account should only be made if it has not already been registered.

What should the developer do to ensure that users do not overwrite each other's updates to the same Account if they make updates at the same time? A)

B)

C)

D)


What should the developer do to ensure that users do not overwrite each other's updates to the same Account if they make updates at the same time? A)

B)

C)

D)

Suggested Answer: D Vote an answer
When multiple users are updating the same record at the same time, there is a risk of overwriting each other's changes. Salesforce provides a mechanism called 'record locking' to prevent this from happening.
Option D is correct because including FOR UPDATE in the SOQL query locks the retrieved records for the duration of the transaction. This prevents other transactions from updating the record until the current transaction is complete, which is essential for avoiding race conditions where two users might overwrite each other's updates.
Option A is incorrect because while adding a try/catch block around the update operation is good practice for handling exceptions, it does not prevent overwrites from concurrent updates.
Option B is incorrect because using upsert instead of update does not address the problem of concurrent updates. The upsert operation is used to either insert a new record or update an existing one based on whether a record with a matching ID or external ID already exists.
Option C is incorrect because FOR UPDATE should be used in the SOQL query to lock the records, not in the SELECT statement itself.
Salesforce Developer Documentation on Locking Statements: Locking Statements Salesforce Developer Blog on Handling Concurrency in Apex: Handling Concurrency in Apex
Option D is correct because including FOR UPDATE in the SOQL query locks the retrieved records for the duration of the transaction. This prevents other transactions from updating the record until the current transaction is complete, which is essential for avoiding race conditions where two users might overwrite each other's updates.
Option A is incorrect because while adding a try/catch block around the update operation is good practice for handling exceptions, it does not prevent overwrites from concurrent updates.
Option B is incorrect because using upsert instead of update does not address the problem of concurrent updates. The upsert operation is used to either insert a new record or update an existing one based on whether a record with a matching ID or external ID already exists.
Option C is incorrect because FOR UPDATE should be used in the SOQL query to lock the records, not in the SELECT statement itself.
Salesforce Developer Documentation on Locking Statements: Locking Statements Salesforce Developer Blog on Handling Concurrency in Apex: Handling Concurrency in Apex
by Ziv at Jul 17, 2026, 08:19 AM
0
0
0
10
Comments
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.
Report Comment
Commenting
You can sign-up / login (it's free).