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
basha skbasha sk 

How to execute command button twice by one click ?

HI,
   Actually I'm trying to ceate a record in external system for that I have developed
   a REST api and it works perfectly for creating a record.
  
   Problem:
   ---------
  
  Step1 : By clicking the command button once in visualforce page first it sends request to external
          system and returns the response as status  ok.But no record creates in external system this time.
  
  
  Step2 : Now this time by clicking the command button twice from visualforce page it sends request to third party
          and creates a record in external system.
         
          How can I avoid double clicking a command button in visualforce for creating a record.
         
          This is my page :
          -----------------
         
<apex:page standardController="Test__c"  extensions="UserExport" sidebar="false">
    <apex:form >   
        <apex:panelGrid columns="2">
          <apex:pageBlock Title=" Registration Form">
            <apex:pagemessages />
                 <apex:pageBlockSection >
                     <apex:inputField value="{!Test__c.First_Name__c}" /> <br/>
                     <apex:inputField value="{!Test__c.Last_Name__c}" /><br/>
                     <apex:inputField value="{!Test__c.Login__c}" /><br/>
                     <apex:inputField value="{!Test__c.Registration_Password__c}" /><br/>
                     <apex:inputField value="{!Test__c.Conform_Password__c}" /><br/>
                     <apex:inputField value="{!Test__c.Company_Name__c}" /><br/>
                      <apex:inputField value="{!Test__c.City__c}"/> <br/>
                     <apex:inputField value="{!Test__c.State__c}"/><br/>
                     <apex:inputField value="{!Test__c.Country__c}"/><br/>
                     <apex:inputField value="{!Test__c.Mobile_Phone__c}"/>   <br/>
              </apex:pageBlockSection>         
                    <apex:commandButton value="Register" action="{!processButtonClick}"/>
       </apex:pageBlock>
         
         
    Thanks,
Ishwar ShindeIshwar Shinde
Why can't you make 2 callouts in processButtonClick method of extension? If 1st callout is successful, perform 2nd callout.

Thanks,
Ishwar Shinde
Ishwar ShindeIshwar Shinde
You can use chaining of continuation to solve this - https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_continuation_chained_callouts.htm

Thanks,
Ishwar Shinde
P.S. : Mark this as best ans if this helps.