Salesforce Lightning Flow is a powerful tool for Admins to be able to automate business processes and ensure users are following processes. I’ve written a lot about Salesforce Flows at developingflow.com and believe that admins can extend their point and click capabilities by learning Salesforce Lightning Flow.

One of the negative pieces of Salesforce Flow in the past, however, is that in order to redirect the Flow, you needed to set the retURL variable with a known variable (meaning not a newly created record) or you needed to wrap your Flow in a Visualforce Page. Lightning Components have given us the ability to wrap the Flow in a Lightning Component as well, but this takes a little bit more work to get setup.

There is another way to be able to redirect a Flow dynamically based on variables in the Flow. Instead of wrapping a Flow in a Lightning Component, you can instead add the Lightning Component as part of the Flow, either through a Flow Screen or through a Flow Action. There are two use cases here. One is to automatically redirect the user, to not only a record, but to any URL with customized parameters, and the other is to allow the User to click a button to decide where they would like to be redirected to.

Here’s a look at how the buttons look:

Lightning Buttons in Flow Screen to Redirect User

So how does this work? Well, using a single Lightning Component, we can either automatically redirect via a Core Action in the new Flow Builder or we can add the Lightning Component to a Screen.

Flow Core Action to Redirect Flow to URL

In the above example, you are setting the “Redirect URL”, an input variable to the Lightning Component, with the URL that you would like. In this instance, I created a simple formula field (image below) to set the Contract that was created in the Flow as the finish location.

Finish Location Formula - Contract

Additionally, you can add the Lightning Component to the Flow Screen and set the Button Label and the Redirect URL. In the instance below, I am setting the Contract as the Redirect URL for the first Lightning Component and the Account as the Redirect URL for the second Lightning Component. The screenshot below is the admin setup of the screen above with two buttons on it asking to “Navigate to Contract” or “Back To Account”.

Edit Flow Screen - flowURLRedirect

I’m sure you’re thinking to yourself, but we still need to create the Lightning Component! Well, you’re half correct. Correct that you need a Lightning Component, incorrect that you need to create it. I’ve created a package for you to be able to download this component. This Lightning Component takes in any URL that you send it through the Flow, so this can be reused again and again with multiple Flows.

As Admins, sometimes we hit our point and click limits. Before Salesforce released Lightning, this usually meant (although not always) that Development would need to be done and Admins would lose some, if not most, control. With Salesforce Lightning, Development should extend an Admin’s control, through input and output variables. A Lightning Component could have been written to send a user to a single URL, which would then require a new Lightning Component for each URL. Instead, by rethinking the way that Admins and Developers interact, the same Lightning Component can be reused again and again by an Admin, in the way that the business needs, allowing an Admin to extend their control with the custom Development work and gaining more power as an Admin.

Go to the Flow Components page to install!

5 comments

  1. First, thank you for putting this together. I have a Flow I am working on to walk my Users through creating a Case for service requests. The final piece is getting the flow to end with them either on the Case they just created via the flow OR on the Home page. The installation and setup went perfectly, however it doesn’t redirect when tested. I have tested it in debug mode in the flow and activated from the Account, via a Detail Page Button. I am using the Detail Page Button so I can grab data from the beginning record.

    My problem is that, in both cases, it fails to go anywhere once I click the button to navigate to the new Case. There is no error message, it just doesn’t do anything. What am I doing wrong?

    1. Hi C.J.,

      The Flow needs to run in lightning experience mode for it to work as it is a lightning component that does the refresh. It won’t redirect you in debug, but you should be able to see the url that it “would” open if it wasn’t in debug.

      I’ve used the redirect component in a flow screen to show a button to redirect to home or the case, user choice, and if they click next, then just pick one or the other.

      I would recommend using the Flow Components Run Flow Button, if you pass in the Id of the record to recordId, then you should be able to query all the information you need from the Account inside the flow without using the full detail page button.

      Can you give any more information into your setup?

      1. Rich,

        Thanks for the quick reply. I tested the flow in both debug mode and in Lightning, from the Account Page, using the aforementioned Detail Page Button. I set up a flow screen with two of your Redirect Flow Lightning Components; one navigating to the new Case, the other navigating to either the Home page or the original Account.

        In debug, clicking either has no effect. I went back and added the Finish navigation button to the Flow Screen and doing that allowed me to see the debug log for that screen when I clicked next after clicking either Redirect Flow button had no effect. It showed me what the URL formulas looked like (which was correct) but the “Selected Navigation Button” was “Next”, not one of the Redirect Flow component URLs. In both tests, the Case was created.

        In Lightning, I achieved the same effect both with and without the “Finish” navigation button, respectively.

        Regarding your Run Flow Button, it doesn’t allow me to specifically pull in the Record ID and Current User ID as the Detail Page Button or a standard Flow Component would. Otherwise I would have used it in a heartbeat.

        I cannot convey how much I appreciate your timely response and your willingness to take time out of your day to help me figure this out. Please let me know if you have any further questions about my setup or any direction on how to proceed further. If I do not hear from you again until Monday, have a fantastic weekend. Thank you, again.

      2. Hi C.J.,

        You can send over the recordId. If you create a variable in the Flow, “recordId” (with that case type), it will send in the record id to that variable, just ensure the variable allows input. You can get the current user id by creating a formula and getting it that way, no need to “send it” to the flow, you can get it from the flow.

        Rich

  2. Rich,

    Thank you! I got it to work! My only issue now is that I cannot select the flow redirect for use on a Home Page. How can I do this?

    C.J.

Leave a Reply

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

%d bloggers like this: