How to Navigate to a Record in Salesforce Flow

newsletter Jul 06, 2024

We're officially halfway through 2024.

Halfway into the year, are you ahead of schedule, on track, or behind where you want to be on your 2024 goals?

I'm behind... I definitely want to spend a little more time on my most important 2024 goals.

Now that we've had a moment of reflection, let's jump into this week's tip: how to navigate to a record from a flow.

In a screen flow it's often useful to redirect a user to a newly created record.

And, sometimes, it can be useful to refresh the current record page a user is looking at.

This solution handles both use cases.

First, you'll want to go to the Salesforce help site here, and take a look at the three pieces of code.

Don't worry, you don't need to understand it at all. This is a simple copy and paste operation I'm about to walk you through.

Next, we'll head to Salesforce and open the developer console.

And we'll click File -> New -> Lightning Component.

Type NavigateToRecord as the name and press Submit.

You'll land on a page like this

On this page, paste the code from the help site labeled Component Markup.

It will look like the above image when you're done.

The next step is to, on the right hand side, click both the word Controller and the word Design once.

This will create the space for you to paste the other two pieces of code.

Now:

  1. Paste the code from the help site labeled Design Resource into the Design file
  2. Paste the code from the help site labeled Client-Side Controller into the Controller file
  3. Make sure to save each individual tab by pressing Ctrl + S

The following screenshot shows which code to copy.

Hard part done! After saving, you can close the developer console.

Now we can move on to the flow.

In any screen flow that you'd like to include this action in, click the +Action button on the canvas to add a new action.

Then search for NavigateToRecord (what we named our component).

Click the action, name it, and then specify the record Id of the record you want to send the user to.

This recordId could be for a newly created record, or even the record that started the flow (to refresh the page).

Here's an example:

Once you configure the action, save and activate the flow. And you're done!

Now any time a user goes through the screen flow, the action will fire, and redirect them to the record you chose.

Sweet!

Another good thing about this action is that can be built directly in a production environment. No deployment or developer needed.

Hope you find this one helpful. I use it all the time.

 

Best,

Nick

SalesforceĀ Saturdays

Join the Salesforce Saturday newsletter. Every Saturday, you'll get 1 actionable tip on Salesforce technology or career growthĀ related to the Salesforce Industry.

We hate SPAM. We will never sell your information, for any reason.