Access Apex-Defined Variables from Outside Flows

Now you can pass values into Apex-defined variables when you launch a flow from a Subflow element, from a Visualforce page, or as an action. You can also access the values of Apex-defined variables as the flow runs or when it finishes. Previously, you could access only variables of other data types from outside flows.

Where: This change applies to Lightning Experience and Salesforce Classic in Enterprise, Performance, Unlimited, and Developer editions.

Why: The Apex-defined data type lets you represent complex data that doesn’t fit well in Salesforce objects. For example, you can set up External Services to access external web objects. To work with those web objects in flows, set up flow variables that use the Apex-defined data type.

When used with Subflow elements, you can better organize and manage your Flow implementations. Suppose you have a complex, multi-step business process that revolves around an Apex-defined data type. Now you can use a master flow that passes complex data among other flows when running them via Subflow elements. This implementation lets you improve specific steps in the process without affecting other steps in the process.

How: Configure each Apex-defined variable that you want to access from outside the flow as available for input, output, or both. This example shows an Apex-defined variable named “Cart_Item” that is available for input and output.Edit Variable window showing the Available for input and Available for output checkboxes

Then you can access the Apex-defined variable from outside the flow. This example shows how a Subflow element in another flow can set the value of the “Cart_Item” Apex-defined variable.New Subflow window showing the Cart_Item variable being set by referencing an Apex-defined variable in the master flow

Note

Note

Some user interfaces outside of Flow Builder can’t pass values into Apex-defined variables in flows. For example, Lightning App Builder lets you select an Apex-defined variable in the flow, but you can’t select a compatible value to pass into it.