0

I have 2 quick Action buttons, which call same lightning components.

How should I know on component initialization that which Quick Action triggered lighting component?

  • What is your use case? – Jayant Das Nov 5 '18 at 21:03
3

Unfortunately that's not possible today. One way I can think of doing this would be having a parent wrapper Lightning component to pass an attribute to the child lightning component to let the child component know about current context. Something like below. This will even work when you have same component in multiple actions on a same page. Only issue is you will end up having that many parent wrapper components means if you use the component at two different places you will end up creating two different parents!

Look at @KeithC answer in How to call a WebService method from a Lightning Component that replaces a Classic JavaScript button?

Pseudo code: In the below example you have 2 different parent components and same child component.

Action1:

<aura:component>
<aura:attribute
<aura:attribute name="context" type="String" default="context1"/>
    <!-- Optional coponent attributes here -->
    <!-- Optional HTML markup -->
<c:child context={!v.context}/>
</aura:component>

Action2:

<aura:component>
<aura:attribute
<aura:attribute name="context" type="String" default="context2"/>
    <!-- Optional coponent attributes here -->
    <!-- Optional HTML markup -->
<c:child context={!v.context}/>
</aura:component>

In the meanwhile you could upvote for the idea Ability to pass parameters to lighting component from quick actions in lightning

0

On a totally different train of thought, if you wanted to navigate to a full-screen Lightning Component you could implement lightning:isUrlAddressable in your component and have your buttons be link buttons instead. Then each button could pass different parameters to the component.

https://developer.salesforce.com/docs/component-library/bundle/lightning:isUrlAddressable/documentation

Be aware that URL addressable components get cached for when you come back to them again. You will want to implement an init method that checks the state parameters, but also an onPageReferenceChanged method which re-checks the state and re-inits the component to whatever you want it to be when you return to it again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.