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
Ravi Kumar 6740Ravi Kumar 6740 

How to call two functions from Lightning:Select onchange handler?

Best Answer chosen by Ravi Kumar 6740
Suraj Tripathi 47Suraj Tripathi 47

Please find the solution.

<lightning:select aura:id="select-id" value="{!v.Data}" onchange="{!c.showRecords}" name="picklist" label="Show Data"  >
        <option value="">-- None --</option>
        <aura:iteration items="{!v.YourList}" var="obj">
            <option value="{!obj.value}" text="{!obj.label}"></option>
        </aura:iteration>
    </lightning:select>
	
	
	
	
	({
    "showRecords" : function(cmp){
        var action1 = cmp.get("c.method1");
        var action2 = cmp.get("c.method2");

        action1.setCallback(this, function(response) {
            if (state === "SUCCESS") {
                $A.enqueueAction(action2);
           }
        }
        action2.setCallback(this, function(response) {
            if (state === "SUCCESS") {
                
           }
        }
        $A.enqueueAction(action1);
    }
}


Please mark it as the Best Answer if it helps you.

Thank You

All Answers

AbhinavAbhinav (Salesforce Developers) 
Hi Ravi ,

You can try calling one from another or you can create a third method on your controller that calls both methods you want and just call that one on  onchangen

reference:
https://salesforce.stackexchange.com/questions/142890/how-to-call-multiple-functions-from-change-attribute-in-lightning-component

https://trailblazers.salesforce.com/answers?id=9063A000000Dz2cQAC

Thanks!
Suraj Tripathi 47Suraj Tripathi 47

Please find the solution.

<lightning:select aura:id="select-id" value="{!v.Data}" onchange="{!c.showRecords}" name="picklist" label="Show Data"  >
        <option value="">-- None --</option>
        <aura:iteration items="{!v.YourList}" var="obj">
            <option value="{!obj.value}" text="{!obj.label}"></option>
        </aura:iteration>
    </lightning:select>
	
	
	
	
	({
    "showRecords" : function(cmp){
        var action1 = cmp.get("c.method1");
        var action2 = cmp.get("c.method2");

        action1.setCallback(this, function(response) {
            if (state === "SUCCESS") {
                $A.enqueueAction(action2);
           }
        }
        action2.setCallback(this, function(response) {
            if (state === "SUCCESS") {
                
           }
        }
        $A.enqueueAction(action1);
    }
}


Please mark it as the Best Answer if it helps you.

Thank You

This was selected as the best answer