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
Jay16Jay16 

Prevent duplicate records being created via custom extension


Hey guys, 

I have a custom object which has a custom button. When pressed it calls a standard controller with custom extension and creates 2 or 4 child records depending on how many are required. The only problem is that if the user presses the same button again, they get 2 or 4 more identical records. 

Does anyone have any ideas as to how I can prevent this from happening? I'm not after code, just general thoughts. 

So far my best idea is to add a check box that gets updated when records are created or deleted (note that i will use 2 buttons, create all and delete all for this to work) and then a visualforce rule to prevent records from being created if the checkbox is true. Ideally I would like to keep this as code light as possible. 

Thanks in advance!
J