Newer Version Available
Interview Class
Namespace
Usage
SOQL and DML limits apply during flow execution. See Per-Transaction Flow Limits in the Salesforce Help.
- Create the object directly in your class by using:
- No namespace: Flow.Interview.flowName
- Namespace: Flow.Interview.namespace.flowName
- Create the object dynamically by using createInterview()
Examples: Starting Flow Interviews
- Whether the interview is created statically, with Flow.Interview.myFlow, or dynamically, with createInterview().
- Whether the flow is managed or local.
- Interview Created Statically for a Local Flow
-
- Interview Created Dynamically for a Local Flow
-
- Interview Created Statically for a Managed Flow
-
- Interview Created Dynamically for a Managed Flow
-
Example: Getting Variable Values
Interview Methods
The following are instance methods for Interview.
createInterview(namespace, flowName, inputVariables)
Signature
public static Flow.Interview createInterview(String namespace, String flowName, Map<String,ANY> inputVariables)
Parameters
Return Value
Type: Flow.Interview
Usage
Use this method to dynamically create a Flow.Interview object for the start() method.
- If the variable is cast to a specific flow, you can use myFlow.myVar to
access a variable, where myVar is the name of the variable.
- If the variable is of type Flow.Interview but not cast to a specific flow, you must
use getVariableValue() to access the flow's variables.
If the flow doesn't exist in the current org, a TypeException is thrown.
createInterview(flowName, inputVariables)
Signature
public static Flow.Interview createInterview(String flowName, Map<String,Object> inputVariables)
Parameters
- flowName
- Type: String
- The flow’s API name.
- inputVariables
- Type: Map<String,Object>
- Initial values for the flow’s input variables.
Return Value
Type: Flow.Interview
Usage
Use this method to dynamically create a Flow.Interview object for the start() method.
- If the variable is cast to a specific flow, you can use myFlow.myVar to
access a variable, where myVar is the name of the variable.
- If the variable is of type Flow.Interview but not cast to a specific flow, you must
use getVariableValue() to access the flow's variables.
If the flow doesn't exist in the current org, a TypeException is thrown.
getVariableValue(variableName)
Signature
public Object getVariableValue(String variableName)
Parameters
- variableName
- Type: String
- Specifies the unique name of the flow variable.
Return Value
Type: Object
Usage
The returned variable value comes from whichever flow the interview is running. If the specified variable can’t be found in that flow, the method returns null.
This method checks for the existence of the variable at run time only, not at compile time.
start()
Signature
public Void start()
Return Value
Type: Void
Usage
- Autolaunched Flow
- User Provisioning Flow
When a flow user invokes an autolaunched flow, the active flow version runs. If there’s no active version, the latest version runs. When a flow admin invokes a flow, the latest version always runs.