Using retURL to Redirect Users When Flows Finish

Using retURL to Redirect Users When Flows Finish

There are multiple ways to launch screen flows, such as using URL buttons or hyperlink formula fields. When launching a screen flow through these methods, it’s important to define what should happen when the flow is completed. By default, when a screen flow finishes, a new flow interview begins, redirecting the user back to the first screen. To redirect users to a different page after they click the "Finish" button, you can include the retURL parameter in the flow URL. Using the retURL parameter will enhance the overall user experience.

What is retURL Parameter?

The retURL is a variable you can append to the end of your flow URL when creating a button or hyperlink. While you can hardcode the retURL parameter, it can also be made dynamic. There are several options available for setting a dynamic return URL with retURL.

Redirect DestinationRelative URLExample
Chatter_ui/core/chatter/ui/ChatterPage_ui/core/chatter/ui/ChatterPage
Home pagehome/home.jsphome/home.jsp
List viewobjectCode?fcf=listViewId001?fcf=00B0Y000007FhjXUAS
Object home pageobjectCode/o003/o
Specific recordrecordId0011n00002vULQVAA4
Visualforce pageapex/pageNameapex/PaymentWizard
Web tabhttp://servlet/servlet.Integration?lid=webTabIdhttp://servlet/servlet.Integration?lid=01rD0000000A87h

How to Use the retURL Parameter

Here is the format that you have to follow in order to use the retURL parameter.

/flow/flowName?retURL=url

url is the relative URL and it can be one of the options listed above. For instance, here is a URL button that launches a flow called "Mass_Delete_Case_Records" and then navigates to the home page of the Case object.

/flow/Mass_Delete_Case_Records?retURL=500/o

Here is another example that passes the ID of the Work Order record to the flow. Then it returns back to the same record.

/flow/Work_Order_Approval_Reminder?WorkOrder={!WorkOrder.Id}&retURL={!WorkOrder.Id}

retURL Limitations

  • Pay attention to how you are writing retURL because it is case sensitive. Therefore, if you write RetURL, it won't redirect the users.
  • It is not possible to use a variable from the flow as the value for the retURL parameter. It means that it is not possible to use the retURL parameter to navigate to a newly created record.

How to Navigate to a Newly Created Record

Navigating to a newly created record is a very common request and unfortunately it is not possible to achieve this using the retURL parameter. This is because you set the parameter before launching the flow. Since you don't know the new record's Id from the beginning, you cannot navigate to a newly created record. However, you can easily solve this issue by displaying a link as a button.

Here is how to achieve this:

1- Create a formula resource that returns the URL of the new record. Read this post to learn how to create this formula, but essentially, you can use /recordId. You can call it {!RecordLink}

2- Create a text resource and enter the HTML below in plain text mode. You can call it {!FinishButton}.

<a class="slds-button slds-button_brand" href="{!RecordLink}" target="_self">Finish</a>

This text template will display the record link as a "Finish" button.

3- Hide the footer and display this text template using the Display Text component. It will look like the standard Finish button but actually it is a link that looks like a button.

Custom Finish Button

At the end, your final screen should look/work like this.

How to Navigate to a Newly Created Record without Using retURL

Be the first to comment

Leave a Reply

Your email address will not be published.


*