Create a Record Link Dynamically in Flow

Create a Record Link Dynamically in Flow

By

There are times when you build a flow that you want to provide a link to a record, but you want this link to be created dynamically. It cannot be static or hard-coded. Now, you know what I think about hard coding things, especially in Flow.

The business problem

Addison Dogster is the system administrator at Hello Mochi, and Mary Markle is the operations manager. When a new contact record is created, Mary wants the confirmation screen to include a link to the newly created record. Can Addison implement this, and how?

The solution

Why yes, it is indeed possible and, added bonus, it can be generated dynamically. Win-win! Addison solves this problem using a formula that dynamically generates the Salesforce URL for the newly created record.

Here’s a demo of the solution.

Screen flow with link to the newly created contact record

The automation solution (screen flow) looks like this.

(1) We ask for the contact’s first and last name. (2) Then, we create the new contact record using the input from the screen flow and store the newly created contact record in a variable. (3) Lastly, we create the confirmation screen, letting the user know that we created the contact with a link to the newly created contact record.

Configured screen flow

Let’s see how Addison creates her screen flow.

In the flow, she configures the following Flow resources.

A. She needs to create a variable resource to store the newly created contact record ID.

Best practice tip: Provide a description so you and other/future admins know what this Flow resource is used for.

Here’s how Addison configures the variable resource.

  • Resource Type: Variable
  • API Name: varNewContact
  • Data Type: Text
  • Availability Outside the Flow:
    • Available for input: Unchecked
    • Available for output: Unchecked

Configured varNewContact variable

B. Addison needs to create a formula to store the dynamically generated URL to the contact record. Because the contact record ID does not exist until the record is created, she needs to create the link dynamically. While she could have hard coded the beginning URL, we want the link to work in every environment this is tested in and not just production.

Best practice tip: Provide a description so you and other/future admins know what this Flow resource is used for.

Here’s how Addison configures the formula resource.

  • Resource Type: Formula
  • API Name: NewContactLinkFormula
  • Data Type: Text
  • Formula: LEFT($Api.Partner_Server_URL_260, FIND( ‘/services’, $Api.Partner_Server_URL_260)) & {!varNewContact}

This part of the formula, LEFT($Api.Partner_Server_URL_260, FIND( ‘/services’, $Api.Partner_Server_URL_260)), will create the part of the URL before the record ID, such as https://jenwlee-preview-dev-ed.my.salesforce.com.

This part of the formula, & {!varNewContact}, takes the user to the newly created contact record ID.

Configured formula resource to configure the dynamic URL to the contact record

C. First, Addison configures a Screen Flow element called “Create a Contact” to collect the contact’s first and last name. (Note: For simplicity of this blog post, we’re only collecting two pieces of information. In the real world, you would collect much more. Ensure that you’re including fields that are required when creating a new contact in your org.)

Best practice tip: Provide a description so you and other/future admins know what this Flow element is used for.

She configures as follows.

  • Screen Properties:
    • Show Header
    • Show Footer
    • Next or Finish Button: Use a custom label
    • Next or Finish Button Label: Submit
    • Previous Button: Hide Previous
    • Pause Button: Hide Pause
  • Add a Name Component Text:
    • API Name: ContactName
    • Fields to Display: firstName,lastName
    • Label: Contact Name

Screen with the configured header and footer

Configured Screen that shows the Contact Name component

D. Next, she adds a Create Records element calledCreate a Contact” where she’ll create a new contact based on the first and last name provided in the screen flow. Then, she stores the newly created ID in the variable varNewContact.

Best practice tip: Provide a description so you and other/future admins know what this Flow element is used for.

She configures as follows.

  • How Many Records to Create: One
  • How to Set the Record Fields: Use separate resources, and literal values
  • Object: Contact
  • Set Field Values for the Contact:
    • First Name: {!ContactName.firstName}
    • Last Name: {!ContactName.lastName}
  • Manually assign variables: Checked
    • variable: varNewContact

Configured Create Records element to create the new contact and store the newly created contact ID

E. Lastly, Addison needs a final Screen Flow element called “Confirmation” to show a confirmation message with a link back to the newly created contact record page. To create a link to the record page, she clicks the hyperlink icon and enters “/{!NewContactLinkFormula}”.

Best practice tip: Provide a description so you and other/future admins know what this Flow element is used for.

She configures as follows.

  • Screen Properties:
    • Show Header
    • Show Footer
    • Next or Finish Button: Use a custom label
    • Next or Finish Button Label: Done!
    • Previous Button: Hide Previous
    • Pause Button: Hide Pause
  • Add a Display Text Component:
    • API Name: ConfirmText
    • Text

Addison has successfully created a contact: {!ContactName.firstName} {!ContactName.lastName} [Link: {!NewContactLinkFormula}]

Configured flow Screen with the confirmation message

Configured flow Screen with the link URL

F. She Debugs the flow to ensure it works as expected.

G. She Saves the flow, calling it “Create a New Contact”.

Best practice tip: Provide a description so you and other/future admins know what this flow is for.

Configured flow properties

H. She Activates the flow.

I. Lastly, Addison needs to determine how users will access the flow Screen and configure the component accordingly.

Now, it’s your turn! Try this solution out to dynamically create a record link in Flow, and share with us your use cases on Twitter by tagging @SalesforceAdmns.

Resources

Awesome Admin Highlights from Dreamforce 2023.

Awesome Admin Highlights from Dreamforce 2023

In a flash, Dreamforce 2023 has come to a close, leaving us with a clear vision of how #AwesomeAdmins are empowered to shape the future of business. Whether you joined us in person or streamed content on Salesforce+, this year’s Dreamforce illuminated a path to a 🌟bright future🌟 for admins, driven by the latest technology […]

READ MORE
Upgrade to Hyperforce with Confidence Using Hyperforce Assistant

Upgrade to Hyperforce with Confidence Using Hyperforce Assistant

Demystifying Hyperforce for admins As a Salesforce Admin, you might be wondering, what is Hyperforce? Put simply, Hyperforce is Salesforce’s new public cloud-based infrastructure designed to support Salesforce services for the future. A cloud-native architecture, Hyperforce will replace our existing first-party infrastructure and provide significant benefits to our customers, including data residency, enhanced security, availability, […]

READ MORE
Cloudy standing next to text that says, "Create Workflows in Data Cloud Using Flow."

Create Workflows in Data Cloud Using Flow

Are you a Salesforce Admin who wants to streamline and optimize key Data Cloud processes such as ingestion, identity resolution, calculated insights (CIs), segments, and activation? If so, you’ve come to the right place. In this blog post, we’ll explore how you can use Salesforce Data Cloud and Flow together to create custom workflows to […]

READ MORE

Have an Idea for a Story?

We are all about the community and sharing ideas.
Do you have an interesting idea or useful tip that you want to share?

SHARE YOUR IDEA