We are in process of converting our existing JS buttons to Quick Action + lightning Components.

There are some 2/3 buttons which do the same functionality with very little difference among them. For Example, Creating a case with subject field Test1 in buttonA, Test2 in button B, Test3 in button C.

So ideally i should have 3 quick actions with 3 components. But since this is a very little change, i do not want to create another new component+controller and would like to reuse 1 component for all 3.

My Solution:

document.getElementsByClassName('modal-header slds-modal__header')[0].innerText

Using the above js code, i get the modal header name (which is nothing but the quick action label).

Finally based on the value from above js, i assign value to the field in sObject.

Is this correct approach or is there any predefined function which can be used for getting the quick action name?

  • The solution using document.getElementsByClassName('modal-header slds-modal__header')[0].innerText is not possible after API Version 38.0. Putting it out there in case someone tried this just like me.
    – tumbledore
    Apr 29 at 9:04

I think what I would recommend here is to create nested components. So you have a parent component that will call the component you want to call here, and you can pass in attributes to the component. You technically will end up with 4 components, but the one is reused. So for example:

<aura:component >
    <aura:attribute name="specificParameter" type="String" required="true" />

        {!v.specificParameter} is passed from the parent.

and in your parent component that is the quick action, you call your main component (ChildComponent) with the specific parameters you need.

<aura:component implements="force:lightningQuickAction" >
    <c:ChildComponent specificParameter="Test 1" />

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.