Hrushikesh Khirid
Hrushikesh Khirid

Reputation: 1

Concurrent update on record in Salesforce

In system I am developing, user can access particular page which is used to make DML operation on custom object. I want to fulfill following business case :

  1. User A opens a Page made changes on page but did not click Save.
  2. At the same time User B opens a page made changes and click Save. User B data got saved in record.
  3. Now user A came and click Save. But as data is outdated I want to prompt user that "you are over righting the latest update. Do you want to continue."

Is there any faster out-of-box way available to achieve it ?

Upvotes: 0

Views: 1256

Answers (2)

Kyle Olson
Kyle Olson

Reputation: 36

Assuming this is in a VisualForce page, you could check if the value has changed inside your Save method.

  1. Query for the LastModifiedDate of all records you may change, and save that in your controller. This should be done in your controller's constructor and/or anywhere you re-load the record(s).
  2. In the save method, first query the record(s) again to check if the LastModifiedDate has been changed. If it has been changed, prompt the user.

Upvotes: 1

naveen
naveen

Reputation: 159

Assuming you are trying to insert a record into an object.

You can write a validation rule on that object. Check if that record is already inserted or not and show an error message.

Regards,

Naveen

autorabit

Upvotes: 0

Related Questions