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
Yadhagu LYadhagu L 

how to get quick action button name in aura component?

I have two quick action buttons both the buttons calling the same aura component, I need the name of the button which is clicked, From that i have two contents to display based on the button name. If this scenario is possible give me a solution, Thanks
SubratSubrat (Salesforce Developers) 
Hello Yadhagu ,

In an Aura component, you can retrieve the name of the quick action button that was clicked by utilizing the "e.force:showToast" event and accessing its parameters. Here's how you can achieve this:

Create an Aura component to handle the quick action:
QuickActionComponent.cmp:
<aura:component implements="force:lightningQuickActionWithoutHeader">
    <!-- Define your component content here based on the button name -->
    <aura:attribute name="buttonName" type="String" default="" />

    <aura:handler name="init" value="{!this}" action="{!c.handleInit}" />
</aura:component>
Create the controller for the component:
QuickActionComponentController.js:
({
    handleInit: function(component, event, helper) {
        var actionAPI = component.find("quickActionAPI");
        var args = { actionName: "lightning:isUrlAddressable" };
        
        actionAPI
            .getActionInfo(args)
            .then(function(result) {
                var actionName = result["actionName"];
                component.set("v.buttonName", actionName);
                
                // You can use the "actionName" to conditionally render content or perform other operations based on the clicked button.
                if (actionName === "Button1") {
                    // Perform specific actions for Button1
                } else if (actionName === "Button2") {
                    // Perform specific actions for Button2
                }
            })
            .catch(function(error) {
                console.log("Error: " + error);
            });
    }
});
Use the "force:lightningQuickActionWithoutHeader" interface to make the component available as a quick action.
When the component is used as a quick action, the "handleInit" function will be executed, and it will determine the name of the clicked button using the "actionName" parameter.

Hope this helps !
Thank you.