Set Flow Input Variables

When you embed a flow in a custom lightning-flow component, give the flow more context by initializing its variables. To create a flow in your component, set the lightning-flow component’s flow-api-name attribute to the API name of the flow that you want to use.

To use this component, build a flow with the Salesforce Flow Builder first. The component includes the navigation buttons Back, Next, Pause, and Finish.

If your flow has custom Lightning web components or Aura components, then you can’t use lightning-flow on Experience Cloud sites that use Lightning Web Runtime.

In the component's Javascript file, create a list of maps and pass that list to the flow-input-variables attribute.

You can only set variables at the beginning of an interview, and the variables you set must allow input access. If you reference a variable that doesn’t allow input access, attempts to set the variable are ignored.

For each variable that you set, provide the variable's name, type, and value. For type, use the API name for the flow data type. For example, for a record variable use SObject, for a text variable use String.

This method in the JavaScript file returns an array of values for a number variable, a date collection variable, and a couple of record variables. The Record data type in Flow Builder corresponds to SObject here.

This example component gets an account via an Apex controller. The Apex controller passes the data to the flow's record variable through a wire in the JavaScript file.