Newer Version Available
Set Flow Variable Values from a Visualforce Page
The following table lists the ways you can set a flow’s variable, sObject variable, and sObject collection variable values using Visualforce.
| Method | Variables | sObject Variables | Collection Variables | sObject Collection Variables |
|---|---|---|---|---|
| Without a controller | ![]() |
|||
| With a standard controller | ![]() |
|||
| With a standard List controller | ![]() |
|||
| With a custom Apex controller | ![]() |
![]() |
![]() |
![]() |
| With an Interview Map | ![]() |
![]() |
![]() |
![]() |
Setting Variable Values without a Controller
This example sets myVariable to the value 01010101 when the interview starts.
Setting Variable Values with a Standard Controller
You can use standard Visualforce controllers to set variables by passing in data from a record. This example sets the initial value of myVariable to the Visualforce expression {!account} when the interview starts.
Setting an sObject Collection Variable Value with a Standard List Controller
Because sObject collection variables represent an array of values, you must use a standard list controller or a custom Apex controller. This example sets myCollection to the value of {!accounts} when the interview starts.
Setting Variable Values with a Custom Apex Controller
For finer control over your Visualforce page than a standard controller allows, write a custom Apex controller that sets the variable value, and then reference that controller in your Visualforce page. This example uses Apex to set myVariable to a specific account’s Id when the interview starts.
This example uses Apex to set an sObject collection variable myAccount to the Id and Name field values for every record with a Name of Acme.
Setting Variable Values with an Interview Map
This example uses an Interview map to set the value for accVar to a specific account’s Id when the interview starts.
Here’s a similar example that sets the value for accVar to a new account when the interview starts.
