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
Rafael MottaRafael Motta 

How can I disable motion a button after clicking on the ?

Hello everyone.
I have a button on campaigns, which is responsible for activating a campaign and create a case , this is done based on some criteria (if there are members in the campaign , if the campaign is on the status: planned, once created send a message users added in the campaign etc ... ) , it works, the problem is that it takes too long to run and the user click on the button many times because the user thinks that the system does nothing and pressed several times, this which brings accordingly, duplication of cases. I would appreciate if I could help make the user as first press this button , it will lock or hide or something to prevent duplicate cases are created. I leave below the code underliner that I made. part is the code I wanted to add to the button will lock .

Beforehand thank you very much.

{!requireScript("/soap/ajax/33.0/connection.js")} 
{!requireScript("/soap/ajax/33.0/apex.js")} 

var cam= '{!Campaign.Id}'; 

if('{!Campaign.Status}' == '{!$Label.NPS_CampaignPlannedStatus}'){

   if({!Campaign.CountCampaignMembers__c} > 0)
   {
            function checkForm(form)
        {

 if(!{!Campaign.Cases_Created__c}){
     
                   var s = sforce.apex.execute("NPS_Send_CampaignEmail", "activarCampana",        {cID:'{!Campaign.Id}'}); 
           top.location.reload();
        }
        
              
        else{
            alert('{!$Label.NPS_CampaignActivateError1}');
        }
         form.myButton.disabled = true;
    return true;
  }

   }
    else{
         alert('{!$Label.NPS_CampaignActivateError2}');
    }
}
else{
   alert('{!$Label.NPS_CampaignActivateError3}');
}
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Add this logic to disable your button on first click
var a=document.getElementsByName('disable_me')[0]; 
a.className='btnDisabled'; 
a.onclick='';
SalesFORCE_enFORCErSalesFORCE_enFORCEr
Here disable_me is the api name of the button