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
Jaikish ThamarasserilJaikish Thamarasseril 

Data integrity and concurrency...

Is there any infrastructure in the force.com platform to prevent dirty update? Consider the following chronological scenario :

1) User A views record R1and clicks edit
2) User B views record R1and clicks edit
3) User A modifies R1 and saves
4) User B modifies R1 and saves

    This sequence would overwrite changes made by User A. Is there a version management mechanism that would detect that save in step 4 will detect that the entity has been updated before and prevent it?
bob_buzzardbob_buzzard
There is in the standard UI, but not in Visualforce - there's more information at:

https://developer.salesforce.com/page/Building_Visualforce_Pages_Using_Standard_Controllers_Part2

scroll down to the Concurrency Considerations section.
Jaikish ThamarasserilJaikish Thamarasseril
Thanks Bob for the quick reply. Is there some versioning mechanism that can be enabled on an entity to help in doing a custom implementation when a VF page is involved.
bob_buzzardbob_buzzard
You have to do it yourself - before you save the record, query the latest version from the database and check the last modified date/time - if that is later than the value recorded in your record in the Visualforce controller, you know that someone else has beaten you to it.
Jaikish ThamarasserilJaikish Thamarasseril
Thanks.