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:
- Go to Setup in Salesforce.
- Select Object Manager.
Choose the object where you want to create the hyperlink formula field (e.g., Account, Contact).
2. Create a New Field:
- Click on Fields & Relationships.
- Click New.
3. Select Formula Data Type:
- Choose Formula as the data type.
- Click Next.
4. Enter Field Details:
Enter the field label (e.g., Record Link).
- The field name will be auto-populated based on the label.
- Select Text as the formula return type.
Click Next.
5. Define the Formula:
- In the formula editor, use the HYPERLINK function to create the URL.
- 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.