How To Redirect Users to a Record from Screen Flow

Screen Flow lacks the functionality to automatically redirect users to a specific record upon completion of the flow. For instance, when creating a contact for an account using Screen Flow, there is no built-in feature to direct users to the newly created contact record. Currently, after creating a contact, users remain on the account record by default, which can lead to a subpar user experience.

The good news is that you can easily incorporate this feature in Screen Flow within minutes by utilizing a code snippet provided by Salesforce. No coding experience is required – simply copy and paste the code to enhance your user experience without any hassle.

Here is a short video showing you exactly how to do this in less than 5 minutes.

Here is the code used in the Flow:

Component Markup

<aura:component implements="force:lightningQuickAction, lightning:availableForFlowActions">
   <aura:attribute name="recordId" type="String" />
</aura:component>

Design Resource

<design:component>
   <design:attribute name="recordId" label="Record ID" />
</design:component>

Client-Side Controller

({    invoke : function(component, event, helper) {
   // Get the record ID attribute
   var record = component.get("v.recordId");
   
   // Get the Lightning event that opens a record in a new tab
   var redirect = $A.get("e.force:navigateToSObject");
   
   // Pass the record ID to the event
   redirect.setParams({
      "recordId": record
   });
        
   // Open the record
   redirect.fire();
}})

Do note that this re-direction will not work when you are running the flow from:

  • Flow Builder
  • Flow detail pages or list views
  • Web tabs
  • Custom buttons and links

This redirection will work when you are running the flow from:

  • Lightning page
  • Experience Builder page
  • Quick Action or
  • Utility Bar

Introducing Mastering Salesforce Flows Training Course

Liked this post? We are now offering a complete self-paced, video-based training course on Mastering Salesforce Flows. The course comes with downloadable step-by-step PDF guides, unlimited access, free upgrades, community discussion area, free preview and more. For more details, please click here.

Need Help with Flows?

Need advice on Flows? I also offer advisory & consulting services on Salesforce Flows. So, whether you want to create new Flows or migrate existing automations (Workflow Rules, Process Builder, Triggers) to Flows, I can help you analyze, design, plan & review. To initiate a discussion, please submit the contact form here stating your requirement or schedule a discussion at this URL.

References & Useful URLs

Leave a Comment

Your email address will not be published. Required fields are marked *

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

Scroll to Top
Introducing All Access Pass