+ Start a Discussion

Resolving Edit Conflicts Through APEX

Hello All,


I have been looking for a way to resolve edit conflicts through APEX.


For example:


User A opens a contact for edit

User B opens the same contact for edit

User A updates the contacts' title and saves

User B updates the contacts' phone number and saves


Normally this would produce an error message to user B saying that user A has editted the contact and ask user B to redo their work.


I would like to find a way to merge the changes. The two users have not made any changes which would be in conflict, so I want the change from user B to succeed. Is there a way to do this?


Thanks for you help.



If the record is dirty you want to merge the changes.


I know stuff like Hibernate (or pretty sure) supports stuff like that.


With Force you could certainly check to see if the data is dirty (check last modified when you loaded vs last modified when you save).


As to the rest of it I am sure there is a way to do it but none of them are probably pretty.


If there was only a limited number of fields you were concerned with you could try that historical field changes thing but you only get a couple of those.


Beyond that I would imagine you would need to create your own table to store field level changes and compare against those. Probably could do it all on a trigger level.