Newer Version Available

This content describes an older version of this product. View Latest

Interview Class

The Flow.Interview class provides advanced Visualforce controller access to flows and the ability to start a flow.

Namespace

Flow

Usage

The Flow.Interview class is used with Visual Workflow. Use the methods in this class to launch a trigger-ready flow or to enable a Visualforce controller to access a flow variable..

Example

The following sample uses the getVariableValue method to obtain breadcrumb (navigation) information from the flow embedded in the Visualforce page. If that flow contains subflow elements, and each of the referenced flows also contains a vaBreadCrumb variable, the Visualforce page can provide users with breadcrumbs regardless of which flow the interview is running.

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, which 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.

The following is the Visualforce page that uses the sample flow controller.

Interview Methods

The following are instance methods for Interview.

getVariableValue(String)

Returns the value of the specified flow variable. The flow variable can be in the flow embedded in the Visualforce page, or in a separate flow that is called by a subflow element.

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 currently 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()

Launches a trigger-ready flow.

Signature

public Void start()

Return Value

Type: Void

Usage

This method can be used only with trigger-ready flows. A trigger-ready flow is a flow that can be launched without user interaction, such as from a flow trigger workflow action or the Apex interview.start method. Because trigger-ready flows must be able to run in bulk and without user interaction, they can’t contain steps, screens, choices, or dynamic choices in the active flow version—or the latest flow version, if there’s no active version.