If two users modify at the same time a standar page, Saleforce respond with a message indicating that this register was modify by other user.

In a visualforce it does not happen. It could be possible to check this in a easy way??

  • I believe the question is from end user's perspective and not from a developer perspective i.e. the situation is that two users are running same visualforce page with same record and trying to modify the record. You want to show an error message indicating that someone else is also modifying the record. Is that correct?
    – Anshul
    Oct 19, 2015 at 16:55
  • @Anshul You might be right here. If this is the case my answer is irrelevant and I'll remove it.
    – Dan Jones
    Oct 19, 2015 at 16:56
  • @Anshul you are right,its from end user perspective Oct 19, 2015 at 17:07

2 Answers 2


Well, there can be many different options here. You can also use "FOR UPDATE" clause in SOQL statement to retrieve a record and lock it for updates.

We implemented similar requirement around 5-6 yrs back (there have been lots of new features since then). We used to query the record just before saving it and confirm if the last modifieddate of the record is same as it was loaded initially. i.e.

  1. Page load - load the record
  2. Save record- retrieve record again and compare its last modified date with record retrieved in step 1, if it's the same, then continue, else show an error message to user that someone else has modified the record.

Additionally, you can also build a custom flagging mechanism, wherein you can lock a record and while loading page, you can check if someone has already locked the record (you will need to think through the scenarios wherein some records are displayed as locked falsely)

  • Note that due to the resolution of the audit fields, possible race conditions can occur. I'd personally recommend checking the last modified field and the last modified by ID field to be doubly sure.
    – sfdcfox
    Oct 19, 2015 at 22:13
  • @sfdcfox : Good point
    – Anshul
    Oct 20, 2015 at 18:22

If you use an IDE like Sublime Text with Mavensmate for Salesforce, when you try to save a document it will make you aware that the document has been changed on the server and by who.

enter image description here

However, if you're working on projects that might involve more than 1 Developer. You'd probably want to consider Version Control. BitBucket offers free, private repos to do this or you could pay for a private one through GitHub.

It's a good idea to use one of these two methods so you're aware of another developer's changes. Using Salesforce's built in editor is okay up to a point like this, I'm guessing you'll be overwriting one another's changes. Chances are using an IDE like Sublime you'll find you'll code a hell of a lot quicker too.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .