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.
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.