function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Jay KanchanaJay Kanchana 

Updated fields reverted back when record is open by another user

Hello experts,

This issue wasnt happeneing very frequently and it took us a long time to figure out what was causing it. But it was happening frequent enough that we had to keep our eyes open for the issue  We just figured out what was causing the issue and now we have to figure out a solution. Need help from experts.

We have custom visual force page on a custom object. Internal users can manually edit the record using the visual force page. some of the fields are also updated by our applicants using a portal and the data is brought in using an integrator (boomi). It appears that if the internal user has a prticular record open and while the record is open if boomi updates some of the fields in that record, when the internal user clicks save on the record, the old values that were in the field when they had initially opened the record gets saved back and hence the field updates done by portal/boomi gets reverted back.

I guess this situation will happen if 2 users open the same record and the second user opens and closes the record while the first user still has the record open.

Is there a solution to prevent this from happening?

Thanks for your input.
 
Jay KanchanaJay Kanchana
found this solution. 

http://stackoverflow.com/questions/26887464/concurrent-update-on-record-in-salesforce

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).
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.
ArmouryArmoury
What about the possibility of API overwriting the the record saved through VF?
Jay KanchanaJay Kanchana
Not sure if that would happen? API should hold that record for only few seconds. where as users normally keep record open for minutes and possibly hours.