We’ve updated our component, check out the updated instructions here!

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!

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

  3. Hi, CJ. I’m trying to auto-redirect my Flow when users make a selection from a picklist and click the default “Next” button.

    Right now in Flow Builder I have my Create Records Elements connected directly to an Action, which is using component-ecflc:flowURLRedirect. I have Lightning Runtime turned on in Process Automation Settings.

    I have deployed my flow both as a custom list button, and as a custom detail button — and with the exception of the redirect, these are both working well.

    Flow Debug shows that the formula in my URL resource is valid (i.e., it works when I paste it into a browser), and I am successfully creating records and successfully capturing the new Record ID for the URL formula resource. However my Flow keeps looping back to the beginning of the interview.

    Your blog post seems to pertain mostly to button navigation on the Screen element (which I’d rather not use, since I think my users are going to be confused by the default “Next/Finish” button — which I can’t get rid of). I have also tried to implement the custom navigation button on the Screen Flow anyway, just to rule out the possibility that my Action is the problem, and the Screen flow navigation button does not seem to be functional either.

    Do you have any troubleshooting steps I could try for this?

      1. Thanks for the quick response! I am in Lightning in a Winter ’20 sandbox (Enterprise). I was trying to turn on the button for a related list. I did successfully get the redirect working when I added it to the “next” button in a Screen Flow that I deployed as Flow component on a Lightning Record Page… so my configuration seems to be valid — perhaps it’s primarily an issue with the related list button?

      2. That could be. How are you getting it into the related list? Have you considered using the Run Flow Button from the managed package to run the Flow? It isn’t a requirement, but it displays a button to the user instead of starting the flow immediately, and you can use lightning filtering to filter it out only when needed. Perhaps that would help?

      3. FYI……

        I was able to get everything working…..

        I had to set my output redirectURL on my core action to {!$Flow.CurrentRecord} and it started working.

        Thanks again Rich for your quick responses.

  4. Rich,

    I just successfully installed your flow component package, and I am having the same problems that other are having.

    I have a button called “Deep Clone Package” on a custom object called “Packages”.

    The button calls a flow that clones a package, which is a grouping of OPP Products. the user can rename the package, add a discription, etc..see below for the button URL

    /flow/Deep_Clone_Package?OldPackageID={!Package__c.Id}&retURL={!Package__c.OpportunityId__c}

    I am trying to redirect to the newly created Package for further editing, and like the others, when I get to the redirect component and select either, go to New Package or go to OPP, nothing happens. Just says on that screen.

    I have debugged and can only check the URL variables if I include the finish button, and they look good. Just to be clear…..clicking any of my redirect buttons does nothing, but clicking the finish button shows me what is in the variables assigned to those buttons.

    When I test run the flow i always returns back to the beginning of the flow and not the new record that I just cloned.

    What am I missing??? Your direction is would be much appreciated.

      1. We are using Lightning.

        the button that called the URL I list above was built in classic. I have since created a new lightning action button to call the flow but get the same results.

        We do not use Console

        The newly created record I’m trying to land back on is a custom Object called packages which has a Master Detail Relationship to Opportunities.

        Now the Package object is only visible as a related list, and not as the object itself…..do you think that might have something to do with it.???

      2. It works via the URL, so you can still navigate to packages, I don’t think it would be the issue. What happens if you put the redirect to the package after the screen as the last part of the flow and “force” redirect to the package. Does that work? Can you confirm the URL that you’re putting together?

  5. This Redirect component is a lifesaver! Thank you!

    Is there a way to make the “redirect” component available as an autolaunched Flow? I’m trying to update the stage of my Path using a Process. It works well, except that when the Process updates the field associated with the Path, the Path doesn’t advance unless the user refreshes the page. When I’m trying to walk users through a step-by-step process using Path, adding the “refresh” click is really cumbersome and easy to overlook.

    Others are having this issue in Lightning too: https://success.salesforce.com/ideaView?id=0873A0000003OfdQAE.

    I’m thinking that if we could use your redirect component as an auto-launched flow, it would allow us to pass the ID of the page we are trying to refresh into the Flow to construct the redirect URL, then we could call this auto-launched Flow at the end of a Process to refresh the page.

    Right now, I only see your redirect Flow if I am creating a Screen Flow, not an auto-launched Flow.

    1. Hi Jeff,

      I’m glad it is a lifesaver! 🙂

      Right now, the redirect component is built and follows the Salesforce processes, there is no way for me to change anything (that I’m aware of) to allow it to be visible in an autolaunched flow as the component is designed as a UI element, not an automation element.

      Let me ask this, would a button to refresh the record (without having to refresh the page) be helpful, like the one referenced in the idea? How are you triggering the process to run?

  6. Hi guys,
    First, thanks a lot for making this available to the crowd!

    I face an issue with the Redirect Flow screen component as nothing happens when I click on the button. The flow basically creates a Contact record and related records.

    In my formula ressource (text), I added the variable in which the created Contact is saved. The formula resource looked like this: “/”&{!IB_Contact_Flow_Contact_RecordID} . I then referenced the formula resource in the Redirect URL field of the component but no luck.

    In order to try to find out what the problem I reduced my formula resource to the bare minmum by manually assigning an existing record ID. It now looks like this: “/0030E00000gx0EjQAI”, but still nothing happens when clicking the button.

    Am I doing anything wrong?

    Thanks!
    Xavier

    1. Hi Xavier,

      You’re welcome!

      That should work. How are you launching the flow? (VF Page, button, action, etc?) Can you tell me any more about your setup, like are you using console, mobile app, etc?

      Rich

      1. Hi Rich,

        The ‘New Contact’ flow is launched with a quick action button that is placed on the Account page layout. This account Action has a Lightning Component.

        We are not using console or the mobile app for this, only the standard interface.

        Thanks
        Xavier

      2. Hi again Rich

        I ran another test from a different flow that uses a standard button (no lightning component) and the outcome is the same. Hence I’m wondering if there is anything in security setups that would prevent the URL to be opened upon clicking?

        Cheers
        Xavier

      3. Sorry for the spamming, but I found what the issue is. If the flow is launched from a Quick Action (Flow) then the redirection works like a charm. However it is launched from a Detail Page Button (URL) then the redirection doesn’t happen.

        Is this working as designed? Sorry if i missed the information.
        Would be super awesome if this would work with detail page buttons as they allow us to pass the record ID from which the flow was launched, which is unfortunately not the case with quick action.

        Cheers
        Xav

      4. Hi Xavier,

        You can pass the record id into the Quick Action. If you create a variable named “recordId” and set it available for input, then the record Id will automatically be sent to that variable. Additionally, that does work with our Run Flow button that can be used in page layouts, which allows for you to add a button in a lightning component to launch the flow and can be shown or hidden using the standard lightning component visibility in lightning app builder.

        https://help.salesforce.com/articleView?id=flow_distribute_internal_action.htm&type=0

        In terms of the button itself being launched from a URL, that wouldn’t be something that our package would be able to manage (that I’m aware of), that is how Salesforce manages the flow. I don’t believe that calling a flow from a Visualforce Page would work with the redirect either. We are using Lightning Experience navigation for the redirect.

        Rich

      5. Hi Rich,

        Thanks for your answer, that really helped me to achieve what I wanted!

        Out of curiosity is there anything on your road map that would allow to easily launch a flow from a button added to a related list?

        Cheers, Xav

      6. Hi Xav,

        No, not on my roadmap, something that Salesforce needs to make a change to for my package to be able to work in related lists. You can use a list button to launch a flow in the related list, but it doesn’t work with the lightning runtime navigation, so you can’t redirect to the record. Please make sure to upvote this idea!
        If an action was able to be added to a related list, and we could use a flow action, then it “should” work… https://success.salesforce.com/ideaView?id=0873A0000003TXFQA2

  7. Hey Rich…thanks for making this available! Really appreciate it.

    I, too, am unable to get the redirects to work. My flow is a screen flow triggered via Quick Action as we’re using Lightning. I’ve tried the Redirect Core Action (flow just re-starts) and the Screen button (nothing happens) both together and separately.

    Any thoughts on why we can’t get this to work?

    One of the things that I noticed is that if I put a hyperlink in my final screen and click it, instead of sending me to the URL, it also takes me to the flow and starts the interview again. It’s as if I need a command or something to exit the interview/flow. Not sure if I’m missing something here.

  8. Hello Rich,
    I created a custom detail page button that launches a flow to create a child case from Parent case.I am using lightning Service Console. I tried different options to redirect the flow to Parent case after child case is created but no luck. Does the redirection not work in the case of custom button ?
    Thanks,
    Kausar

  9. Hi Rich, thank for your great components.

    I started a flow from Custom Button with URL in the Account, and created a new Opportunity within the flow, then go to the action to redirect to the newly created Opportunity.

    All setup seems fine but it doesn’t redirect to the newly created opportunity page. It ends up returning to the initial screen and looping within the flow… if you could give some advice, much appreciated.

    For your reference, I screen recorded in the following link:
    https://drive.google.com/file/d/1mqu7FpNmi1uDInVcbXuaAj1M3jijGMdx/view?usp=sharing

  10. Hi Rich,

    I am also facing similar issue pointed out by other folks.

    I have created a Detail Page Button on Order Product Object to create a Job ( Custom Object ). The creation of job happening through a flow.

    Flow is working fine but it’s unable to redirect the user to the newly created record. I have tried both the Record Id & URL component.

    Record Id & URL component works fine if i use a Quick Action instead of Detail Page Button. But Salesforce doesn’t allow us to create a quick action on Order Product.

    To Note : I have already enabled Lightning Run for flow.

    Please let me know if there is any workaround or i am missing something.

    Thanks.

    1. Hi Soumen,

      Would it be ok to launch the flow through the Flow Components lightning component, run flow? It shows a button on the page, just not in the buttons area, but does redirect correctly when launched through that component.

Leave a Reply

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

%d bloggers like this: