1

I have one generic flow. Multiple quick actions can invoke it.

So inside flow, Can we get which quick action has invoked this flow? or Can we pass any values from quick action to flow ?

NOTE : There are 2 quick action on same 'Lead' record.Both the actions invokes same flow. So passing recordID to flow and querying object name won't help.

3 Answers 3

3

You can create a LWC that utilizes CurrentPageReference which will give you the object name and API name of the quick action.

In your Flow, add just your LWC on the first element of your flow.

enter image description here

You'll want to do the following within that LWC:

  • Get the API name of the quick action from the CurrentPageReference
  • Pass the output of the API name of the quick action to a variable in your flow (to use)
  • Immediately progress to the "next step" automatically in your LWC

The CurrentPageReference will look something like this

{
    "type":"standard__quickAction",
    "attributes": {
        "apiName":"Account.flow_test"
    },
    "state" : {
        "objectApiName":null,
        "context":"RECORD_DETAIL",
        "recordId":"XXXXXXXXXXXXXXXXXX"
    }
}

Depending on all the ways this flow can be called (from non-quick actions), you'll want to check the type value is quick action

import { FlowNavigationNextEvent } from 'lightning/flowSupport';
import { CurrentPageReference } from 'lightning/navigation';

@api quickActionAPIName = '';

 @wire(CurrentPageReference)
 getStateParameters(currentPageReference) {        
     //if the page is a quick action, get quick action API name
     if(currentPageReference.type === 'standard__quickAction') {
         this.quickActionAPIName = currentPageReference.attributes.apiName;
         console.log(this.quickActionAPIName); //Account.Flow_Test

     }
     //progress to next element in flow
     const navigateNextEvent = new FlowNavigationNextEvent();
     this.dispatchEvent(navigateNextEvent);
}

Make sure that your variable is available for output (to store in Flow)

...
<targets>
        <target>lightning__FlowScreen</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__FlowScreen">
            <property name="quickActionAPIName" label="The quick action that called this flow" type="String" description="The value the user selected in the picklist" role="outputonly"/>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

Now, you just drag your LWC as the only thing on the screen element and then manually assign the value the LWC outputs to a variable you can use in decisions or whatever logic down the line.

enter image description here

1
  • Thanks Kris, No answer can be perfect than this. Commented Mar 20, 2022 at 15:52
3

Could you replace the Quick Action with a Button? If so, you can create a variable in the Flow called source and run the Flow via a URL, passing the parameter on the querystring. e.g. the URL might be -

/flow/myflow?source=buttonA

2
  • 1
    Definitely a good suggestion +1. The difference to note is that this will open in a new sub-tab in console instead of as a pop up on the record. Commented Mar 19, 2022 at 14:54
  • Yes ,This approach would be good. But it's not showing pop-up. Thanks Commented Mar 20, 2022 at 15:51
0

You could create two Aura Components or Lightning Web Components that invoke the Flow passing some input parameter (one should set the value to "quick action 1" and the other to "quick action 2", for example). Once you have created both components, change the Quick Actions so they execute each of these Components instead of the Flow.

1
  • Okay Thanks bendsito. I will try that Commented Mar 19, 2022 at 9:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .