---
schema_version: "1"
id: a7a32be3e3e5aaa9b7dce4cb91fcd384ea6df3289009671dd5ad9d0fc0a9a764
title: Customize a Visualforce Component to Control the Flow's Finish Behavior
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/flow_distribute_internal_vf_finish.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.flow_distribute_internal_vf_finish.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 8b9b7fb5cb5a913ef70123b48372a5f1c9d9ffe5afebb885d991f8767a3fc8bd
description: By default, users who click Finish start a new interview and see the first screen of the flow. After you embed a flow in a Visualforce page, configure the finishLocation attribute to route users to another page in Salesforce.
products:
  - Flow Builder
  - Salesforce Platform
release: "264"
---
# Customize a Visualforce Component to Control the Flow's Finish Behavior

By default, users who click **Finish** start a new interview and see the first screen of the flow. After you embed a flow in a Visualforce page, configure the `finishLocation` attribute to route users to another page in Salesforce.

## Set `finishLocation` with the `URLFOR` Function

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-platform_automation-264-0-0-production-enus/60568438-ec7e-4665-acd1-7c80dcbe60d5/images/icon_note.png)

Note

- You can’t redirect flow users to a URL that’s external to your Salesforce org.
- Don’t call the `Auth.SessionManagement.finishLoginFlow` method and the `finishLocation` attribute in the same flow. `Auth.SessionManagement.finishLoginFlow` indicates the end of a Visualforce page login flow. If `finishLocation` is in the same flow, `` `finishLocation` `` runs when the flow starts, giving users full access to the session.

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.

```markup
<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.

```markup
<apex:page>
          <flow:interview name="MyUniqueFlow" finishLocation="{!URLFOR('/001D000000IpE9X')}"/>
          </apex:page>
```

For details about `URLFOR`, see Functions in the Visualforce Developer’s Guide.

## 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 details about `$Page`, see Global Variables in the Visualforce Developer’s Guide.

## 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.

```markup
public class myFlowController {
    
    public PageReference getPageA() {
        return new PageReference('/300');
    }
    
    public String getPageB() {
        return '/300';
    }
    
    public String getPageC() {
        return '/apex/my_finish_page';
    }
}
```

- `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.

Here’s a sample Visualforce page that references the controller and sets the flow finish behavior to the first option.

```markup
<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. They see the first screen of the flow, without the record, 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.