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
kabukabu 

How to prevent double click on a custom Detail Page Button?

I have account Detail Page custom button and Content Source is visual force page in the Button Setup.
VF page is used to call a controller method to execute and create Record in ERP system using REST API.
<apex:page standardcontroller="Account" extensions="CreateCustomerController" action="{!createCustomer}">
</apex:page>
When user double clicks it is creating duplicate customer records in our ERP system.

How can I prevent this happening.? 
Can I disable the button after first click? 
If you have asome other solution I can try. I have seen some post like below but I am using VF page as content source so don't want use this.
https://developer.salesforce.com/forums/?id=906F000000093GUIAY


 
Ankit AroraAnkit Arora

You can use Status as well, which will show a loding UI but I don't think it will prevent clicking the link again. In general practice we use YUI Loading which again shows a loding UI but disable the complete background page, that will probably prevent the double click on link. 

 

Hope this will help as an example : https://developer.salesforce.com/page/Visualforce_blog

kevindotcarkevindotcar
IDK if this helps in your particular situation, but I had a similar problem and I solved it by making the custom button a URL instead of javascript or VF.

User-added image