In Automation, Blog, Flow, Salesforce Lightning, Tips & Tricks, Training & Certification

Redirect Flow in Lightning Experience

In Lightning Experience there are two ways you can use Flows currently. You can use the beta Feature to drop a Flow into a Lightning Page using the App Builder.  There are some other limits including: lightningPage

  • Only able to pass the record ID into the Flow
  • No Redirect Option
  • Really limits you to only screen flows from a practicality stand point

Don’t get me wrong, this can still be a pretty cool thing with the right use Case. But what if you want to do a Redirect?

Back to good old Visualforce pages. These still will work with Lightning. This sample assumes you want to return to the starting record. So the scenario is you start on an Account Record, Click a button, Finish the flow and go back to the Account.

<apex:page standardController="Account">
    <flow:interview name="LIghtningTest" finishLocation="{!URLFOR('/'+Account.ID)}" />

The URLFor Formula is the key here. You can also use this as a redirect to other records as long as you know the record id BEFORE the Flow starts. If you want to redirect to a record you created or did a lookup to get in the Flow, you need a controller extension.

Here’s a sample of the visualforce page controller

<apex:page controller="FlowRedirectController">
<flow:interview name="Universal_Redirect_Flow" finishLocation="{!redirectTo}" interview="{!redirectId}">
and the Apex Class
public class FlowRedirectController{	
	public Flow.Interview.Universal_Redirect_Flow redirectId {get; set;}
 	public String returnId;
    public PageReference getredirectTo(){ //This returns the page you want to go to
        if(redirectId != null) {
        	returnId = (string)redirectId.getVariableValue('vRedirectId'); //this gets the variable from the flow
    	PageReference send = new PageReference('/' + returnId);
    	return send;


Recommended Posts
  • Sumit Datta

    Great Article, Brian

    This really helped me in learning FLow redirection for Lightning Experience.


Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.