function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
pranavshahpranavshah 

Redirect To Originating List View After finishing the flow in Salesforce

Hi All,

I have one requirement where once the screen flow is finished, then its should redirect to list view from where it was originated rather than setting the default value in the return URL.

Can anyone let me know how it can achieved.

Thanks,
Pranav Shah
Lexi CharlieLexi Charlie
Hello,

To achieve the requirement of redirecting to the original list view after a screen flow is finished, instead of setting the default value in the return URL, you can implement a custom redirection mechanism. Here's a step-by-step guide on how to do this:

1. Identify the Origin List View:
You need to determine the source or origin of the list view. This could be based on the page or button that triggered the screen flow. You may need to pass this information as a parameter or use some context variable.
2. Capture the Origin View Information:
Before launching the screen flow, capture information about the original list view. This might include its URL, parameters, or any other relevant details. Store this information in a variable.
3. Execute the Screen Flow:
Let the screen flow run as usual, allowing the user to complete the required actions.
4. Custom Redirect at the End:
After the screen flow is finished, instead of relying on the default return URL, you can use Apex code or a custom JavaScript button (if you are working with a web application) to redirect the user to the original list view.
For example, in Apex code, you can use the PageReference class to construct the URL for the original list view and then use the PageReference method to redirect the user.
Here's a simplified code snippet:
PageReference originalListView = new PageReference('your_original_list_view_url_here');
originalListView.getParameters().put('parameter1', 'value1'); // Add any required parameters
originalListView.setRedirect(true);
return originalListView;
If you're working with a web application, you can use JavaScript to achieve a similar result by manipulating the browser's URL.
5. Test and Verify:
Test this solution thoroughly to ensure that the user is redirected to the correct list view with the appropriate parameters intact.

By following these steps, you can ensure that the user is redirected to the original list view after completing the screen flow without relying on default values in the return URL. This provides a more seamless and user-friendly experience.