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
DharaneshDharanesh 

Concurrent Record Creation

Hello Team,

I have a scenario where users are opening the same VisualForce page in two different browsers and clicking on Save button on the same time, resulting in creating two records. In the code i tried to check to see if the record exists then don't save or else save,but since it is from two different browsers, the record does not exists and end up with two records again after save.

Please suggest some options on how to restrict this behaviour.

Thank you
3 Creeks3 Creeks
Is it possible to create a unique key on the object that is based on the data that is being saved?  Then if you have the insert statement within a try/catch block, if the key is being duplicated the insert will not happen.  Instead you will go into the catch block and you can then process however you want for the situation, ie. show a error message, silently fail the insert, etc.
sathishkumar periyasamysathishkumar periyasamy
please answer below question, So I will give you the best answer
1. are user duplicating same information both browser VF page? or different information?
2. data always coming through only VF? or data loader as well?
DharaneshDharanesh
Hi Sathish kumar,

No, users are having different information, but when the record is inserted duplicate records are getting inserted with same data.
Yes, data is always coming via VF, no data loader
DharaneshDharanesh
Hello 3 creeks,

I kind of have that option, but at this moment i am not sure how well that fits my situation.
Thank you
3 Creeks3 Creeks
What is specifically is your concern about that option?