Salesforce Lightning Flow Redirect

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

Create a Screen Flow with Screen and Create Record Component.

Salesforce Lightning Flow Redirect

Add Following Fields into the Screen Component

Lookup field (Account)

First Name

Last Name

Mobile Number

Salesforce Lightning Flow Redirect

On the Create Record Component select values shown below.

Salesforce Lightning Flow Redirect

Map the Account Values to Captured values from the flow.

Salesforce Lightning Flow Redirect

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

Salesforce Consulting Services in Australia

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

Salesforce Lightning Flow Redirect

On NewFlow.cmp use the following code

Salesforce Consulting Services in Australia

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 Flow Redirect

On NewFlow.design use the following code

Salesforce Consulting Services in Australia

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)

Salesforce Lightning Flow Redirect

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

Salesforce Consulting Services in Australia

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

Salesforce Consulting Services in Australia

Open the Create Record Screen again

Salesforce Consulting Services in Australia

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

Salesforce Consulting Services in Australia

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 Consulting Services in Australia

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

Salesforce Consulting Services in Australia

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

Salesforce Lightning Flow Redirect

Now the Flow is ready to use on the record page

Salesforce Lightning Flow Redirect

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

Salesforce Lightning Flow Redirect

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

Salesforce Lightning Flow Redirect

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

Salesforce Lightning Flow Redirect

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 Lightning Flow Redirect
Salesforce Lightning Flow Redirect

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

Salesforce Lightning Flow Redirect

Hope this will help you Trailblazers

Check out our other blogs

Learn more: Flow builder

Table of Contents

Talk to our Salesforce Experts.