I have created a custom email template with Opportunity Fields.

In the Email template, I want to create a link that will open a record. The recordId of the is auto stored in a text field on the Opportunity via flow. I am wondering how I could create a URL in the email template to open the Detail Page of the record

This is the approach I was thinking of -

  1. Create a custom label with the URL of the org.

  2. In the email template concatenate the custom label value and the Custom text field value

However this will build the URL as


Instead of


How can i append the /view ?

or is there a way to build a detail record link in the email template?

Edit 06/25/2022

Based on suggestion I was able to get the link to work (see screen shot). However I don't want to hard code the URL as this will break when deployed to other environments.

How can I make the URL dynamic so that it will work in all the environments?

enter image description here

  • How is this different from your earlier question? salesforce.stackexchange.com/questions/379195/… Jun 24, 2022 at 19:34
  • This one is concatenating two strings. string 1 = mydomainname.lightning.force.com, string 2 = recordid Previous question about detail link in a custom email template that doesn't show as a url. In the previous questions thDetailLink already has the url and record id. In the new question, I can't use the detail link, I am building the DetailLink Jun 24, 2022 at 20:02
  • 1
    You can user link of [org/id] and it will redirect the user to the view url (assuming that the user is lightning mode): somethingsomething--SB3.lightning.force.com/aAA6a000000AANaAAa
    – Liron C
    Jun 25, 2022 at 5:18
  • Thanks @LironC I was able to get the url to work based on your response. However, I don't want to hard code the org url as this will not work when deployed to other environments. I have edited my question to show progress. Jun 25, 2022 at 13:48
  • @GroundToCloud from your original question it seems you managed to solve the orgId with the custom label and the issue was only the '/view' addition. Anyway, saw you already solve the issue
    – Liron C
    Jun 25, 2022 at 21:05

2 Answers 2


Finally this is how I solved my url issue in the email template

enter image description here


To get Base URL just simply use

{!MID(Account.Link, 1, LEN(Account.Link)-15)}

After Base URL apply your Logic as usual.

  • do you have the documentation for this?
    – prem22
    Jan 26 at 6:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .