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
RJ12RJ12 

How to perform Two actions on one Button Click?

I have designed a Lightning Component (VF page in the front) for integration. Where I used two buttons, one for generating Access Code, one for generating Access Token. I want to combine 2 buttons into 1. If I click the button, Access code and Access Token must be generated.

My code looks like this:

<button class="slds-button slds-button_brand" data-url="{!'https://XYZ.com/oauth/authorize?client_id='+ v.CUSTOMOBJECT.Client_Id__c+'&amp;scope='+v.CUSTOMOBJECT.scope__c+'&amp;redirect_uri='+v.CUSTOMOBJECT.Redirect_Url__c+'&amp;state=SF'}" onclick="{!c.getAccessCode}">Generate Access Code</button>

<button class="slds-button slds-button_brand" onclick="{!c.getAccessToken}">Generate Access Token</button>
sfdcMonkey.comsfdcMonkey.com
can you share javaScript controller code as well
thanks
RJ12RJ12
@piyush_soni
 
getAccessCode: function(component, event, helper) {
        helper.saveRecord(component,event.target.dataset.url);
    },


    getAccessToken : function(component, event, helper) {
        var action = component.get("c.generateAccessToken");
        action.setParams({
            "xyz":component.get("v.xyz")
        })
        action.setCallback(this,function(res){
            component.set("v.xyz",res.getReturnValue());
        });
        $A.enqueueAction(action);
    },

 
sfdcMonkey.comsfdcMonkey.com
use below code :
<button class="slds-button slds-button_brand" data-url="{!'https://XYZ.com/oauth/authorize?client_id='+ v.CUSTOMOBJECT.Client_Id__c+'&amp;scope='+v.CUSTOMOBJECT.scope__c+'&amp;redirect_uri='+v.CUSTOMOBJECT.Redirect_Url__c+'&amp;state=SF'}" onclick="{!c.getAccessCode}">Generate Access Code</button>
 
getAccessCode: function(component, event, helper) {
 var action = component.get("c.generateAccessToken");
        action.setParams({
            "xyz":component.get("v.xyz")
        })
        action.setCallback(this,function(res){
            component.set("v.xyz",res.getReturnValue());
		// inside call back call your second button heplper function 
		helper.saveRecord(component,event.target.dataset.url);
        });
        $A.enqueueAction(action);       
	   
    },

i hope it helps you.
  kindly Let me inform if it helps you and close your query by choosing best answer if you got your right answer so it can helps others
thanks 
sfdcmonkey.com 
RJ12RJ12
@piyush_soni Only Access Code is generating.
First we need to click on Acess code button and then click on Acess Token button.