How to navigate record detail page in flow

Hello everyone in this post let’s understand how to redirect a user to the record detail page using flow using Local Action. If you are not followed our previous blog please read here, How to send email using flow in salesforce.

How to open a Record Page after finishing Flow?

Scenario: – create a contact record,  after creating navigate the user to the detail page of that record.

How to navigate the newly created record from a flow

  1. Create Screen flow to accept input from users.
  2. Create a contact record.
  3. Call flow action.
Flow design

Let’s start with the implementation.

  1. Go to the object manager then search for flows.
  2. Click for a new flow to create a new one.
  3. Then Drag/Add screen interaction/element.
  4. Drag Name, Email, Phone from component to screen.
  5. Add Api name to all dragged components.
  6. Add Api Name for screen: Create Contact Screen.
  7. Then click done.
Edit screen

Now let’s map these fields to create a contact record.

  1. Drag/Add create record interaction/element to the canvas.
  2. Then Map the fields to the correct contact fields.
  3. How Many Records to Create : One.
  4. How to Set the Record Fields : Use separate resources, and literal values.
  5. Create a Record of This Object : Contact.
  6. Email  : {!Email.value}.
  7. FirstName : {!Name.firstName}.
  8. LastName : {!Name.lastName}.
  9. MobilePhone : {!Phone.value}.
  10. Manually assign variables = true.
Create records flow

Next, we are creating a new resource that will be storing the id of a contact and then passing this id to the flow action. Let’s see how to create a new resource.

  • In Store Contact ID in Variable click for new resource.
  • Choose resource type as variable.
  • Add API name : ContIds.
  • Data Type :  Text.
  • Then click done.
New Resource

After creating a new resource type variable, choose the resource type in creating the record element as below.

  1. In Store Contact ID in Variable : {!ContIds}.
  2. Then Click Done.
Create record 1

Now let’s create an action to navigate a user to the record detail page. To do that, we will create a new lightning component.

Go to the developer console, then create a new lightning component named DetailPageNavigation.


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


The recordId attribute is declared in the design resource so that it’s configurable in the local action.

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


When the local action is executed, the flow calls the invoke method, which uses the force:navigateToSObject event to navigate to the created record.

({    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
      "recordId": record
   // Open the record;

Now we are done with our lightning component, so let’s connect a lightning component to flow action. To do that follow the below steps.

  1. In flow drag/Add action to the canvas.
  2. Then search for the lightning component created: DetailPageNavigation.
  3. Label: Navigate to detail page of record.
  4. In Set Input Values, Choose record id to: {!ContIds}.
  5. Then Click Done.
Create Action

Congratulations now we are done with our flow, which will redirect a user to the detail page of the record. Let’s see how it looks.

redirect a user to the detail page of record in flow

Bonus : How to add Fault Path in Flow

Suppose if your flow failed in the case of required fields or others, then how to show the error message in flow. To that, you need to add fault error in flow. Let’s see how to create it.

In contact record Lastname is the mandatory field, suppose if missed that field while creating a record, then we need to show the error message, then follow the below steps to create it.

  1. Click on create record interaction/element.
  2. Then click add fault path.
  3. Then add screen interaction/element.
  4. From the component add display text .
  5. Add display text api name : Error_Msg_Screen.
  6. Then in Insert resource add : {!$Flow.FaultMessage}.
  7. Then choose api name of screen : Error_Screen.
  8. and click done.
Fault path screen 1
Fault path screen 2

Now you are done with the fault path, let’s check out how it looks completely.

Navigate to record detail page in flow

Congratulation now we are completely done with our flow. If you find this blog helpful feel free to share it with your friends. If you were not followed our other blogs, feel free to check them out.


Related Links

  1. Help And Training Community.
  2. How to Create Record in lightning Component.
  3. How to send email using flow in salesforce.

Sharing Is Caring:

4 thoughts on “How to navigate record detail page in flow”

Leave a Comment