How to create a hyperlink formula salesforce field which when clicked should redirect to a specified record page?

1.6K    Asked by darsh_6738 in Salesforce , Asked on Jun 5, 2024

 There are 2 custom objects linked to each other via lookup. The requirement is to create a hyperlink formula field in the child record which when clicked should direct to the parent record page.Is this requirement possible via hyperlink formula field?

Answered by Ella Clarkson

To create hyperlink formula salesforce -

Create a Text formula field with something like ...
HYPERLINK( "/" & Your_LookUp_On_Child__c, "whatever text you want", "_self" ) /* or if you want the record name */ HYPERLINK( "/" & Your_LookUp_On_Child__c, Your_LookUp_On_Child__r.Name, "_self" )
Note 1: Change _self to _blank if you need the link to open in a new page
Note 2: For standard relationship fields, replace
the __c of Your_LookUp_On_Child__c by Id
the __r of Your_LookUp_On_Child__r by nothing
Note 3: If it can be empty, use a conditional clause (IF) to show the HYPERLINK if Your_LookUp_On_Child__c is not empty

Your Answer

Answer (1)

To create a hyperlink formula field in Salesforce that redirects to a specific record page when clicked, follow these steps:

Steps to Create a Hyperlink Formula Field:

1. Navigate to Object Manager:

  1. Go to Setup in Salesforce.
  2. Select Object Manager.

Choose the object where you want to create the hyperlink formula field (e.g., Account, Contact).

2. Create a New Field:

  1. Click on Fields & Relationships.
  2. Click New.

3. Select Formula Data Type:

  1. Choose Formula as the data type.
  2. Click Next.

4. Enter Field Details:

Enter the field label (e.g., Record Link).

  1. The field name will be auto-populated based on the label.
  2. Select Text as the formula return type.
Click Next.


5. Define the Formula:

  1. In the formula editor, use the HYPERLINK function to create the URL.
  2. The general format is

  HYPERLINK(url, display_text, target)

For redirecting to a specific record page, use the following formula:

  HYPERLINK('/' & Id, "View Record", "_self")

This formula constructs a URL that points to the record page using the record's ID and displays "View Record" as the clickable text. The "_self" target ensures the link opens in the same window.

6. Complete the Formula Field Setup:

  • Click Check Syntax to ensure there are no errors in the formula.
  • Optionally, set field-level security and add the field to page layouts.
  • Click Next, then Save.

Example Formula:

Here's a sample formula for an Account object that creates a hyperlink to the account's detail page:

HYPERLINK('/' & Id, "View Account", "_self")

'/' & Id: Concatenates the base URL with the record ID to form the full URL to the record page.

"View Account": The text displayed as the hyperlink.

"_self": Opens the link in the same window.

Final Steps:

After creating the formula field, ensure it is added to the appropriate page layouts so users can see and click the hyperlink.

Test the field by navigating to a record of the object type and clicking the hyperlink to ensure it redirects to the correct record page.

This method ensures that users can easily navigate to the specified record page directly from the hyperlink formula field.














4 Months

Interviews

Parent Categories