Month End Sale Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: simple70

Salesforce Certified Platform Developer II ( Plat-Dev-301 ) PDII Question # 41 Topic 5 Discussion

Salesforce Certified Platform Developer II ( Plat-Dev-301 ) PDII Question # 41 Topic 5 Discussion

PDII Exam Topic 5 Question 41 Discussion:
Question #: 41
Topic #: 5

A developer created an Apex class that updates an Account based on input from a Lightning web component. The update to the Account should only be made if it has not already been registered.

Java

account = [SELECT Id, Is_Registered__c FROM Account WHERE Id = :accountId];

if (!account.Is_Registered__c) {

account.Is_Registered__c = true;

// ...set other account fields...

update account;

}

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.

Add a try/catch block around the update.


B.

Use upsert instead of update.


C.

Use FOR UPDATE in the SOQL query.


D.

Include LastModifiedDate in the query to make sure it wasn’t recently updated.


Get Premium PDII Questions

Contribute your Thoughts:


Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.