Flow: How To Redirect Your Users When Flows Finish (retURL)
I’ve been postponing the writing of this article because, to be honest with you, I don’t use retURL for flow that often! However, it doesn’t mean that I don’t care about a good user experience. In this article, I will share three different types of redirection, including my personal favorite!
Why Redirection?
For Autolaunched Flow – Reduce The Clicks
When you finish an autolaunched flow using a button, you will see “Your flow finished” and the page stays there. Your users will have to close that window and go back to the original one. What’s even worse is when displaying the button in the current window. Your users will then have to go find the original record like in the example. Redirection can make these clicks all go away.
For Screen Flow – Prevent Unintended Runs
Redirection is a nice-to-have for autolaunched flows, but it can actually prevent errors for screen flows! Confusingly if you launch a screen flow using buttons or Lightning pages, the flow will re-run and re-run until your users close the windows. Without redirection, your uses might execute the flows many more times than intended. Like in example, the user couldn’t see the flow has finished and cloned many cases without knowing.
Different Ways To Redirect
We will present three different ways to redirect your users and what types of flow are applicable. Note that you don’t have to choose only one. You can use either one of them, or retURL + Screen, or Quick Action + Screen.
- retURL (Autolaunched/Screen)
- Quick Action (Screen)
- Screen Element (Screen)
retURL – When Using Buttons
retURL is a variable that you can add to the end of your flow URL when creating a button. You can use a static value which links to a specific page (ex. retURL = 5005I00000FkTTPQA3), or a dynamic value so it links to different pages based on where you launch the flow (ex. retURL = {!Case.Id}).
You can find different possible destinations in this help article, but the most common one I use is the recordId one. For example, when creating a detail page button for Case, paste in your flow URL as below.
/flow/flowName?retURL={!Case.Id}
Several important notes when using retURL:
- You can only use retURL in buttons, not actions.
- retURL is case sensitive, so make sure you type it exactly like that.
- We cannot use the variables in flow with retURL. If we redirect to records, it can only be the original record.
- If there are already a question mark in your flow URL, use & in front of retURL instead:
Ex. flow/flowName?varId={!Case.Id}&retURL={!Case.Id})
Setup
Result
Quick Action – When Having Screen Flows
If you have a screen flow, the easiest way is to launch it with quick actions. It is now possible to use recordId in quick actions so this solution will save you a lot of time.
However, if you use Quick Actions on Case or Work Order objects, the actions will show up in Chatter if feed tracking is enabled. Check out this article for more details.
Result
Screen Element – When Having Screen Flows
If we use the solutions above, the outcome would be quite limited. We cannot redirect to the newly created records, or the buttons might show up in a different place. So I want to introduce my favorite redirection – by using a Screen Element. I found this solution myself and not sure if Salesforce would recommend this, but it is working so well that I want to share it with you so much 🙂
It is a really nice solution that you can use for every scenario (buttons, actions, or on Lightning page), but be sure to test thoroughly before you deploy it.
* NOTE * Instead of hardcoding the URL, you can utilize the $API global variable to get the current domain. This will be extremely helpful if you are deploying your solution from the sandbox.
Result
Hi, would be nice to show under retURL-WhenUsingButtons as a result for Autolaunched flow; you showed for a screen flow. I am saying this, because in my case there is a few miliseconds delay, where the name of the flows is still ugly visible. Thanks
Hi Paula, I converted my screen flow to autolaunched flow and tested again, but everything is working fine for my side. Would you share a screen recording (can send it to me privately if you prefer) and we can trouble shoot together? If no obvious bug is found, you might need to raise it to SF support for the performance issue.
so helpful – tried all three and they work perfectly, thank you!!!
That’s great to hear, thank you!
Hey :), great article. Just wondering if you know of a solution which simply closes the “popup” window once a flow/user clicks “finish”. (when the flow is triggered by a custom button, URL for SF classic).
Thanks Jordan:) Unfortunately I don’t think it’s possible in the URL button. However I would suggest using a screen flow + Action instead, so the pop-up will be closed automatically. (With a Action, the UI looks better too). Hope this helps!
Hi Melody,
Great article. I have a requirement to display a link to the record in the email that was triggered by the flow. Do you know how this can be accomplished? I read somewhere that $Record.Link merge field can be used on the email template but I can’t seem to find it.
Thanks Ryan! I am not aware of the $Record.Link field, but you can utilize the $API global variable: https://salesforce-flowsome.com/how-to-use-global-variable/#api. Hope this helps!
Great article, thanks Melody!
Hello, Melody!
First of all, excellent article and blog!
I have the following scenario: I created a Flow that is available in a listview button. The user selects the records and when clicks on the button, the Flow updates a field in these records. In this scenario, is it possible to redirect the user back to the listview or to another listview?
Thanks for the nice words Leonardo! Great question – it should be possible. You have to configure the button like in screenshot:
The behavior has to be: Display in existing window without sidebar or header
and the retURL should be objectCode?fcf=listViewId (object code is the prefix)
Hope this helps!
Wow, it worked! You can’t imagine how happy I am now! Thank you very much for the help!!!
My pleasure Leonardo. Happy to help!
How do you find the listviewid for a custom object on a related list for the account?
Hi!
Great article and excellent blog! I find myself here often and it’s extremely helpful.
I have a use case for the 3rd option you presented, I have a screen flow that prompts the user to create an opportunity and I would like to take them directly to the newly created op.
I tried hardcoating the url with {recordId.Id} as you did in your example but flow gave me an error saying I couldn’t use merge fields.
How do I use the $API Global Variable as you mentioned? Would be nice to have an example of how to apply this.
Thanks!
Thanks Lloyd! If you face this kind of error, the first thing to check is whether you enter the merge fields correctly. For example it should be {!recordId.Id} (with the ! mark) instead of {recordId.Id}. The best way is to use a resource picker in a formula or on a display text, instead of manually writing it.
For the api, you can refer to here: https://salesforce-flowsome.com/how-to-use-global-variable/#api There is an example of how to write the formula. Hope this helps!
hii
helpful article, can we reeduce button click and autolounched flow at the end redirect to specific URL. how?
Hello! So my understanding is that retURL only links to the relative url within your org and it’s not possible to redirect user to an external url.
Darn good info. Thanks
Hi! I Use the retURL and this works, but the result of my flow is not showing up on the page. Is there any way to reload the flow after it finished? As manually reloading helps load the result of the flow. Kind regards,
Tim
Hi Tim, currently there is no way to reload the page in Flow. I believe it might be achievable through APEX
Hi Melody,
thanks for the great content. I have a very simple flow which Assign current user as owner and update s the Opportunity Stage. I really don’t want any extra clicks for the User so came across your solution.
I’ve an auto triggered flow and this is my button URL. The flow runs but the page still doesn’t refresh. Any ideas much appreciated!
/flow/Opportunity_Assign_and_Process_Auto_Launch?recordId={!Opportunity.Id}&retURL={!Opportunity.Id}
I can get my retURL to open the related list where the button resides, but I cannot figure out how to open the newly created record…???
Hi. How do you redirect to the record?
This is very helpful, but hoping you may have a suggestion to help my scenario. I am triggering a screen flow from a button on my list view page. The flow is creating a new lead. Is there any way to return to the newly created lead? I been successful in using the return actions from record pages, but I can’t seem to get this to work from the list view page. Thank you!!
Hi, how can redirect to new record that I created in the flow? The flow is creating a new Opportunity. Is there any way to return to the newly created Opportunity from a list botton?
FYI: For option 3 “screen element” with a URL in the display text component, make sure you have either the pause or finish buttons selected, then uncheck the ‘Show Footer’ setting.
Because even if you UNCHECK the “Show Footer” setting, you won’t be able to save the flow if you also select to hide all the navigation buttons.