5

I have a screen flow that calls a Lightning Component (Lead Search). The component allows a user to filter for certain records (opportunities, accounts, and leads). The controller APEX class returns either a list of the records or a null value.

My question is: is it possible to return a value from a Lightning Component to a flow? I want to take the value and run decisions and other screens based off of the values.

Ideally it would look something like: (with Lead Search Screen and Display Records Screen as lightning components)

enter image description here

I know we can do this with APEX and Invocable method or process plugin, but I am not sure how I would go about this with a screen call.

1 Answer 1

7

You can use the design resource of the aura component bundle to control which attributes are exposed from lightning components to Flows.

Here is the developer document: Aura Component Bundle Design Resources

For instance, lets us say that you have a component attribute in this way,

<aura:component implements="lightning:availableForFlowScreens" access="global">

<!-- Component Attributes--> 
<aura:attribute name="isCreateNewClientAcc" type="Boolean" />

</aura:component>

You can expose this attribute to the flows by adding it to the design resource

<design:component>
     <design:attribute name="isCreateNewClientAcc" Label="Is Create New Client Account?"/>
</design:component>

Now in the flow when you add the lightning component to the screen, you will find the "Is Create New Client Account?" in the Input/Output variables section.

You can assign appropriate flow variables. If you want to pass info from the flow to the lightning component send the flow variable value through the Input variable section, and if you want to pass a value from the component to the flow, then add a flow variable in the output section.

enter image description here

The example talks about a boolean variable, but in your case, you would create a flow variable of type collection and assign it similarly. Later you can use that flow variable in decisions to check if it is null or not.

Note: If you have already added the component to the screen and then you added the design resource to the aura component bundle, you need to refresh the flow to load the latest changes on the aura component.

4
  • this is so great! The only thing is that design doesn't support List data types which is a pretty big blocker.
    – Olivia
    Aug 16, 2019 at 13:31
  • 1
    Hey @Olivia .. it is possible to use List data types too. In my screenshot above the "Client Account Opps" is a List of Opportunities. Please check if you are setting the flow variable "Available for Output" or not. Here is the code snippet: In component: <!-- Component Attributes--> <aura:attribute name="oppsWithClientAcc" type="Opportunity[]" /> In design resource: <design:attribute name="oppsWithClientAcc" Label="Client Account Opps"/> Aug 16, 2019 at 13:43
  • Hi when i am doing the same thing i cannot see store output value section.
    – user109526
    Dec 23, 2021 at 8:57
  • 1
    @user109526 you need to open the "Advanced" section to see the output value information Dec 30, 2022 at 21:44

You must log in to answer this question.

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