Newer Version Available
Interview Class
Namespace
Usage
The Flow.Interview class is used with Visual Workflow. Use the methods in this class to invoke an autolaunched flow or to enable a Visualforce controller to access a flow variable.
SOQL and DML limits apply during flow execution. See Apex Governor Limits that Affect Flows in the Visual Workflow Guide.
Example
1public class SampleController {
2
3 //Instance of the flow
4 public Flow.Interview.Flow_Template_Gallery myFlow {get; set;}
5
6 public String getBreadCrumb() {
7 String aBreadCrumb;
8 if (myFlow==null) { return 'Home';}
9 else aBreadCrumb = (String) myFlow.getVariableValue('vaBreadCrumb');
10
11 return(aBreadCrumb==null ? 'Home': aBreadCrumb);
12
13 }
14}The following includes a sample controller that starts a flow and the corresponding Visualforce page. The Visualforce page contains an input box and a start button. When the user enters a number in the input box and clicks Start, the controller’s start method is called. The button saves the user-entered value to the flow’s input variable and launches the flow using the start method. The flow doubles the value of input and assigns it to the output variable, and the output label displays the value for output by using the getVariableValue method.
1public class FlowController {
2
3 //Instance of the Flow
4 public Flow.Interview.doubler myFlow {get; set;}
5 public Double value {get; set;}
6
7 public Double getOutput() {
8 if (myFlow == null) return null;
9 return (Double)(myFlow.getVariableValue('v1'));
10 }
11
12 public void start() {
13 Map<String, Object> myMap = new Map<String, Object>();
14 myMap.put('v1', input);
15 myFlow = new Flow.Interview.doubler(myMap);
16 myFlow.start();
17 }
18}The following is the Visualforce page that uses the sample flow controller.
1<apex:page controller="FlowController">
2 <apex:outputLabel id="text">v1 = {!output}</apex:outputLabel>
3
4 <apex:form >
5 value : <apex:inputText value="{!output}"/>
6 <apex:commandButton action="{!start}" value="Start" reRender="text"/>
7 </apex:form>
8</apex:page>Interview Methods
The following are instance methods for Interview.
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 is run. If there’s no active version, the latest version is run. When a flow admin invokes an flow, the latest version is always run.