Configure the finishLocation Attribute in a Flow

If finishLocation isn’t specified, users who click Finish start a new interview and see the first screen of the flow. You can shape what happens when a user clicks Finish on the final screen by using the URLFOR function, the $Page variable, or a controller.
The following sections show the ways you can configure the <flow:interview> component’s finishLocation attribute.

Set finishLocation with the URLFOR Function

Note

Note

You can't redirect flow users to a URL that’s external to your Salesforce organization.

To route users to a relative URL or a specific record or detail page, using its ID, use the URLFOR function.

This example routes users to the Salesforce home page.
<apex:page>
    <flow:interview name="MyUniqueFlow" finishLocation="{!URLFOR('/home/home.jsp')}"/>
</apex:page>
This example routes users to a detail page with an ID of 001D000000IpE9X.
<apex:page>
    <flow:interview name="MyUniqueFlow" finishLocation="{!URLFOR('/001D000000IpE9X')}"/>
</apex:page>

For more information about URLFOR, see Functions.

Set finishLocation with the $Page Variable

To route users to another Visualforce page without using URLFOR, set finishLocation to the name of the destination page with the format {!$Page.pageName}.
<apex:page>
    <flow:interview name="MyUniqueFlow" finishLocation="{!$Page.MyUniquePage}"/>
</apex:page>

For more information about $Page, see Global Variables.

Set finishLocation with a Controller

You can set finishLocation in a few ways with a custom controller.

This sample controller configures a flow’s finish behavior in three different ways.
  • getPageA instantiates a new page reference by passing a string to define the location.
  • getPageB returns a string that is treated like a PageReference.
  • getPageC returns a string that gets translated into a PageReference.
public class myFlowController {
    
    public PageReference getPageA() {
        return new PageReference('/300');
    }
    
    public String getPageB() {
        return '/300';
    }
    
    public String getPageC() {
        return '/apex/my_finish_page';
    }
}
Here’s a sample Visualforce page references that controller and sets the flow finish behavior to the first option.
<apex:page controller="myFlowController">
    <h1>Congratulations!</h1> This is your new page.
    <flow:interview name="flowname" finishLocation="{!pageA}"/>
</apex:page>

If you use a standard controller to display a record on the same page as the flow, users who click Finish start a new flow interview and see the first screen of the flow, without the record. This is because the id query string parameter isn’t preserved in the page URL. If needed, configure the finishLocation to route users back to the record.

Previous
Next