Salesforce Lightning Flow Redirect

Salesforce admins can customize the look and feel of their salesforce experience with flow builder
Here are guided steps to help build interactive custom components without any code

  • Redirect the flow to the Current Record.
  • Adding lighting component into Flow.
  • Adding Flow into Action Button and Home page.

To use all above-mentioned features we need a solid scenario. So I have created a sample flow which is useful for creating Quick contact from anywhere in the org, finally redirect to the actual contact. 

Following 4 Screenshots will explain how to create a sample flow with the above-mentioned scenario.

Create a Screen Flow with Screen and Create Record Component.

Salesforce Lightning Flow

Add Following Fields into the Screen Component

    • Lookup field (Account)
    • First Name
    • Last Name
    • Mobile Number
    • Email Address

      Salesforce Lightning Flow


      On the Create Record Component select values shown below.


      Salesforce Lightning Flow

      Map the Account Values to Captured values from the flow.


      Salesforce Lightning Flow


      How to Redirect from flow to currently created record.

      There is no standard feature to redirect from flow to record page(created by this flow). So we have to write a simple Lighting Component(Aura). This is a very simple component specially no Apex coding required and no test classes at all. I have shared the code in below, Please copy and paste appropriate places. Get into the Developer console then
      NEW→ Lightning Component

      Lightning flow redirect

      Choose any name and select all checkboxes as shown below
      as we are going to use this component in multiple places.

      Salesforce flow redirect

      On NewFlow.cmp use the following code
      <aura:component implements=”force:appHostable,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction,lightning:availableForFlowScreens” access=”global” >
          <aura:attribute name=”recId” type=”String” />
          <aura:handler name=”init” value=”{!this}” action=”{!c.init}” />
      </aura:component>

      Flow


      On
      NewFlowController.js use the following code
      ({
      init : function(component, event, helper) {
              var navEvt = $A.get(“e.force:navigateToSObject”);
      navEvt.setParams({
        “recordId”: component.get(“v.recId”),
      });
      navEvt.fire(); 
      }
      })

      salesforce lightning new flow

      On NewFlow.design use the following code
      <design:component>
           <design:attribute name=”recId” label=”Id of the record” />
      </design:component>

      Salesforce lightning

      Save all files,
      Now the component is ready to use in our flow.
      Let’s get back to the flow which we have created earlier.
      Select a Screen flow to pull our Lighting Component(New Flow)

      screen flow
      Search(Left Side) the NewFlow which will come under Custom, Pull the New Flow on the Screen.

      Lightning Screen
      Create a Text Variable and Place on Id of the record which we defined on
      NewFlow.design



      Salesforce lightning
      Open the Create Record Screen again
      Record Screen

      Scroll down up to the end,
      Select
      Manually assign Variables(advanced)
      Place the ID of the Record on the Store Contact ID in Variable.

      Record

      Now the flow is ready to use as we expected. Now we can use this flow in multiple ways, I am going to show the following 2 ways.

      • Action Button
      • Lightning Pages(Home)

      Go to Buttons, Links, and Action→ Create New Action

      salesforce record

      Select the Flow which we have created now(Quick Contact)

      salesforce new action
      Pull the Action Button into the Page layout where you want to use.

      Account

      Now the Flow is ready to use on the record page

      Account

      Otherwise, we can add this flow into Home Page also
      Go to the Home Page → Edit Page

      Salesforce home page
      Drag the Flow as shown direction in below and select the Quick Contact flow on the right side

      salesforce flow
      Now the Flow is ready to use on the Lighting Page(Home Page)


      Salesforce

      Sample Contact Creation or Test our flow how it is working, the Flow will react the same way in any pages.
      Full fill the following fields



      Salesforce account name

      Once you submit the values the flow redirected to the newly created record.

      Salesforce new created record

Hope this will help you Trailblazers
Check out our other blogs 

Learn more: Flow builder

Leave a Reply

%d bloggers like this: