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
Santosh K SamudralaSantosh K Samudrala 

How to invoke Lightning Action from a Custom Component

Hi All,

We would like to know if is there any way can we invoke Lightning Action from a Custom Component?

Background :  We have a requirement where we need to conditionally render the buttons on the Lightning Page based on the User Role , we are trying to Create a component which verifies the User Role and renders the button conditionally but we are not sure how to invoke the Lightning action on the button click.

Please let me know if you have any suggestions on this.

Thanks in Advance!
Suraj TripathiSuraj Tripathi
Hi Santosh,
You can use aura:if in the Component you want to render the button. 

Example 
<aura:if isTrue="{!v.UserRole == 'xyz'}">
 <div>
<lightning:button variant="brand" label="Submit" iconName="utility:add" iconPosition="right" onclick="" class="slds-button--brand"/>
</div>
<aura:set attribute="else">
    <div class="nobutton"> Else part code </div>
</aura:set>
</aura:if>

Hope it Helps you. Please mark this as solved so that it gets removed from the unanswered queue which results in helping others who are encountering a similar issue.

Regards ,
Suraj
Santosh K SamudralaSantosh K Samudrala
Hi Suraj,

Thank you for your response !

Our issue at hand is about how to invoke the quickAction functionality from a custom component , to reframe this we are trying to build a Custom component in which we will be conditionally rendering the buttons based on the Users role ,  As we dont to build the custom component for each of the button , we are trying to invoke the quick action on click of button.

Please let me know if you have any questions on this.

Thanks.