How To Redirect Users to a Record from Screen Flow (Video 4:52)

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.

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

  • Utility Bar

References & Useful URLs