When sending emails from a Salesforce Flow, hardcoding record URLs can lead to broken links when moving between environments such as Sandbox and Production.
This article explains how to use the Partner Server URL global variable to dynamically generate record links. By using this approach, you can create clean, reliable, and clickable hyperlinks that display as anchor text within rich-text Flow, ensuring consistency across all environments.
To ensure your link works correctly across all environments such as Sandbox, Developer, and Production, use the Partner Server URL global variable. This allows Salesforce Flow to dynamically resolve the correct My Domain URL for the current Salesforce organization, eliminating environment-specific hardcoding.
The Partner Server URL follows a consistent structure that includes the My Domain, the standard SOAP path, the API version, and your Salesforce Organization ID. When these elements are combined dynamically, Flow can generate a valid record link regardless of the environment.
For example, a dynamically generated Partner Server URL may look like this:
`[https://fastslowmotion100-dev-ed.develop.my.salesforce.com][/services/Soap/u/][65.0/][00D8Y000001R6bb]
[Your Company's My Domain URL][Standard Path][API Version][Your Salesforce Organization ID]`
To create a dynamic link to a record within a Salesforce Flow, we need to combine three elements: your company's My Domain URL, a forward slash, and the record's ID.
`LEFT({!$Api.Partner_Server_URL_650}, FIND( '/services', {!$Api.Partner_Server_URL_650}))`
This expression trims the Partner Server URL just before the word "Services," while keeping the trailing forward slash — the result is the base My Domain URL.
`LEFT({!$Api.Partner_Server_URL_650}, FIND( '/services', {!$Api.Partner_Server_URL_650})) & {!Create_Task.Id}`
This second expression appends the Task record ID to the base domain, producing the complete dynamic link. Note: The number 650 in {!$Api.Partner_Server_URL_650} corresponds to API Version 65.0. Use the most recent API version available in your Formula builder.
To see everything together, here is a screenshot showing the different components. A forward slash with a smaller font was added inside the merge fields to prevent it from displaying in email content.
________________________________________________________________________________
Written by: Brad Weller | Forum Ambassador
I'm Bradley Weller, a Senior Solution Architect at Fast Slow Motion and a passionate Flow Fanatic, holding the title of a prior Salesforce FlowFest Champion. I focus on building impactful, scalable Salesforce solutions for businesses. Outside of work, I enjoy spending time with my family and staying active, particularly playing volleyball.
Submissions reflect only the opinions of the user who made available the Submission and not the opinions of Salesforce, regardless of whether the user is affiliated with Salesforce, and may contain or constitute products, services, information, data, content and other materials made available by or on behalf of third parties ("Third Party Materials"). Salesforce neither controls nor endorses, nor is Salesforce responsible for, any Third Party Materials, including their accuracy, validity, timeliness, completeness, reliability, integrity, quality, legality, usefulness or safety, or any applicable intellectual property rights. Any Submissions made available through any message board or forum in response to posted questions, or that otherwise purports to answer any questions, including any questions about Salesforce or Programs, are made available for your general knowledge only and should never be relied upon as answers to your specific questions (even if an answer is marked as a "best" answer or with any similar qualifications). You should always contact Salesforce support for answers to your specific questions. Salesforce has no control over Submissions, and is not responsible for any use or misuse (including any distribution) by any third party of Submissions.
If you have questions, tap into the wisdom of our entire Trailblazer Community here: https://trailhead.salesforce.com/trailblazer-community/feed
005299186

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.