
Flow is the number one automation tool of Salesforce. There are endless things that you can perform using Salesforce Flow. In many cases, you might need to create a link to a record in flow. For instance, if it is a screen flow, you can display a link to the record. So that the users can navigate to the record by clicking the link. Another great use case is sending an email that contains a link to a record.
There are a few ways to create a record link in Salesforce Flow. The goal is to build a link in this format:
https://mydomain.lightning.force.com/recordId
As you can see, the first part will always be the same. You just have to put the record’s id to the right side.
Since the left side of the link will be different in every environment (sandbox and production), it shouldn’t be hardcoded. The important part is to make the link dynamic. So that after deploying the flow between environments, you won’t need to edit the flow and fix the link. Therefore, it is not recommended to put a hardcoded link. So, how can you create a dynamic link?
Create a Link Using a Custom Label
The first option to create a link is using a custom label.
1- Create a custom label in setup and put your Salesforce environment’s url as the value.

2- You can create a formula resource or a text template in order to create the record link. Use the Label global variable in order to bring the custom label that you created in the previous step. Then put a “/” and the record’s id to the right side of the custom label.


After creating a resource for the record link, select the text that you want to display as hyperlink. Then, click on the link icon and use the resource that you created.

This option can be considered as half dynamic, because the first part of the url is still hardcoded in the custom label. When you deploy the custom label to another environment, don’t forget to replace the value. Since it is coming from a custom label, you don’t need to modify the flow. Once you change the value in the custom label, it will be reflected in your flows.

Create a Link Using API Global Variable
The second option is using the Api global variable. This global variable stores the Enterprise Server URL and Partner Server URL values.

There are many options for Enterprise Server URL and Partner Server URL in this global variable. However, as you can see from the screenshot below, they all start with the url of the environment. Therefore, you can use any of them in this use case.

1- Create a formula resource and add one of those global variables. Since you need the environment’s url, you have to use some functions to remove the unnecessary part.

2- After creating the formula, select the text that you want to display as a hyperlink. Then, click on the link icon and use the resource that you created.

This option is completely dynamic and it is the recommended solution. Once you deploy the flow to another environment, you don’t need to change anything.
Example
Here is a simple flow that creates an account record. After creating the account, the Id of the new account record is stored in the variable called {!Create_Account}. Then the flow displays a link for the new record, which lets the user navigate to the new record.

Here is the formula for the record link formula:
LEFT({!$Api.Partner_Server_URL_550}, FIND( ‘/services’, {!$Api.Partner_Server_URL_550})) & {!Create_Account}
After creating the record, it displays a hyperlink for the new account record.

Thank you! The complete dynamic solution really helped, but can you please explain the formula in detail?
Hi,
$Api global variable stores the API URLs.
For example, $Api.Enterprise_Server_URL_140 is the merge field value for version 14.0 of the Enterprise WSDL SOAP endpoint.
In this use case, we just need the URL (we can remove the part after .com). So using a formula, we just remove the part after .com and then we add the record Id. So it becomes the correct link for that record.
Hi Yumi — This is super helpful. Quick question: On the dynamic formula you provided at the end of the article, did you mean to write {!Create_Account} in reference to the record ID or should it be {!recordId} as previously written further above?
Hi Neil,
In that example I am creating a new account and the Id is stored in {!Create_Account} variable. That’s why I used it in the link.
Ok, that makes sense. Thanks!
Thank you!! Very helpful article.
How to send Fault Message from salesforce Flow to Email Template, as there is no $Flow.FaultMessage merge field available in email template?
I can think of 2 possible solutions:
1- Create a text template in flow and use the Send Email core action to send the email, not an email alert.
2- Save the value of the fault message to a custom field and use it in an email template/email alert.
This is great! One question I have is how did you embed your RecordLink_Formula into the “Click Here” text. In my use case I want to embed the record link into the standard field for record name.
Hi,
I selected the text (Click Here) on the screen and clicked the hyperlink icon, then put the RecordLink_Formula.
Thanks, Yumi. Great article.
When I copied across your formula the ‘ marks around /services came through as a different character, so I initially had a syntax error. Easy to fix for anyone else who may have the same problem.
You are right, thank you!
Thanks you Steven! I had the same issue. I really appreciate you taking the time to post that issue here, saved me some headaches.
THANK YOU for posting this. I was going crazy trying to figure out what was wrong. That fixed it!
I am glad that it helped!
Hi Yumi, Can we add Hyperlink to fields in datatable of screenflow? Thanks for your support.
Hi,
Data table can display formula fields with hyperlink. So, once I did a workaround. I updated a field on the record (from the same flow) and then displayed a formula field (that displays a link), which uses the value that I populated.
Had the same issue, did you figure out a resolution?
Hello Yumi
I need one help I want to. Open some screen flow or screen with some value after click link and after save or see screen return.same flow window
Can we open other screen window or screen flow same predefined value
It’s lite urgent
Flows have URLs too, so it is possible to display the URL of the screen flow that you want to open. But in your use case, you might want to use a subflow instead.
Hi, thank you for this article; thought I would need a solution for a hyperlink in text template NOT IN A SCREEN ELEMENT (everywhere on the internet I found only the solution of a hyperlink in a screen element); I need it for a record-trigger flow and unfortunatelly in a text area is Click here
or Click here to open the record.
I would need to be displayed the ‘Click here’ hyperlink without the URL or the usual HTML tags in a text template.
Thank you; I would heartfully appreciate any help!
Hi, you can do the same logic to create a text template with “Click Here”.
Create a formula resource for the record URL and then use it in your text template.
This is a great use case of including a “Click Here” in email bodies.