---
schema_version: "1"
id: 358b26781b2821d6483e7eb988af36cc2235725553cf7f5a38b6c5be92f60b40
title: Construct Effective Custom URL Buttons and Links
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/platform/264-0-0/custom_links_constructing.md
canonical_url: https://help.salesforce.com/s/articleView?id=platform.custom_links_constructing.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: d3ba4ecdd3e393c9ce5ee81367132c537edaf5b04d29ef7b08bd188eeb4c7b3c
description: Use these methods to construct effective custom URL buttons and links.
products:
  - Salesforce Platform
  - Security
release: "264"
---
# Construct Effective Custom URL Buttons and Links

Use these methods to construct effective custom URL buttons and links.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition">
      <colgroup>
        <col>
      </colgroup>
      <tbody>
        <tr class="">
          <td class="slds-cell-wrap" style="vertical-align:top;">Available in: Salesforce Classic</td>

        </tr>
        <tr class="">
          <td class="slds-cell-wrap" style="vertical-align:top;">
            <p>Custom buttons and links are available in: <strong>All</strong> Editions</p>
            <p style="margin-bottom:0;">Visualforce
              pages and s-controls are available in: <strong>Contact Manager</strong>, <strong>Group</strong>,
              <strong>Professional</strong>, <strong>Enterprise</strong>, <strong>Performance</strong>, <strong>Unlimited</strong>,
              and <strong>Developer</strong> Editions
            </p>
          </td>

        </tr>
      </tbody>
    </table>

## Use Merge Fields to Pass Salesforce Data

For example, you can create custom links that search Google for an account name or look up an address on a map.

```
http://google.com/search?q={!Account.Name}
```

```
http://maps.google.com?q={!Account.ShippingStreet} {!Account.ShippingCity} {!Account.ShippingState} {!Account.ShippingPostalCode}
```

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_click-264-0-0-production-enus/5f7d9219-b7b1-4552-8891-f1aba9b289fc/images/icon_note.png)

Note Custom links don’t support data type conversion. When creating custom links to pass data from one Salesforce field to another, the data must match the data type of the fields in which you’re placing it. For example, if you have numeric data, you must pass it to a numeric field.

## Substitute Symbols for Certain Characters

Substitute symbols for certain characters or use `URLENCODE()`.

Due to the World Wide Web Consortium’s URL encoding standards ([W3C](http://www.w3.org/)), certain unsafe characters, such as spaces and punctuation marks, can’t be passed through a URL. Custom buttons and links escape these characters, so you don’t have to URL-encode them.

If you must encode your URL, use the `URLENCODE()` function in the merge field like so: `{!URLENCODE(text)}` and replace text with the merge field or text string that you want to encode.

For example: If the merge field `foo__c` contains `<B>Mark's page<b>`, `{!URLENCODE(foo_c)}` results in: `%3CB%3EMark%27s%20page%3C%2Fb%3E`.

## Link to Visualforce Pages

To link to a Visualforce page, use `URLFOR()` with the relative path to the page, which is /apex/PageName. For example, to link to a Visualforce page called MissionList that isn’t associated with a record, use the following syntax.

```
{! URLFOR( “/apex/MissionList” ) }
```

When you use `URLFOR()` with a Visualforce page, and you want to pass a record ID into the page, you must pass the ID in as a parameter.

```
{! URLFOR( “/apex/Mission”, null, [id=Mission__c.Id] ) }
```

## Point to Salesforce Pages

Use the `$Action` global variable and `URLFOR()` to point to Salesforce pages.

When creating a custom button or link that points to a page in Salesforce, use the `$Action` global variable to construct the link, instead of pasting in the path to the page. Then, if your organization is moved to another server or the URL to the page changes, the link still points to the right place.

To construct the link, use the `URLFOR()` formula function with the `$Action` variable.

```
{!URLFOR( $Action.Case.NewCase, Account.Id )}
```

This custom link on the Account object opens the New Case form, creating the case as a child of the account record. You can use this process for any object that has a lookup to the Account object. To create a record that isn’t a child of another record, or if two objects have no relationship, use `$ObjectType.ObjectName` as the second argument. For example:

```
{!URLFOR( $Action.Case.NewCase, $ObjectType.Case )}
```

`$Action` global variables expect either a record ID or the `$ObjectType`. For example, these formulas create links to the tab and detail page for an account, respectively.

```
{!URLFOR( $Action.Account.Tab, $ObjectType.Account )}
```

```
{!URLFOR( $Action.Account.View, Some_Account_Lookup__c.Id )}
```

The `URLFOR()` function takes additional optional arguments that get passed into the destination as query string parameters. You can use these arguments when overriding a standard action with a Visualforce page to pass in the additional parameters needed by the Visualforce page or its controller. For example, if when closing a case you want to change the value of a custom field on the case called Actual Delivery Date to today, you could use:

```
{!URLFOR($Action.Case.CloseCase, Case.Id, [ actualDeliveryDate=TODAY()] )}
```

You can then override the Close Case action with a Visualforce page and handle setting the value of the Actual Delivery Date field either in that Visualforce page or its controller. See [Using Query String Parameters in a Visualforce Page](http://www.salesforce.com/docs/developer/cookbook/Content/vf_query_string_param.htm) for more information.

## Point to Other Pages in Lightning Experience

Use these Lightning-friendly URL button and link methods to point to other pages in Lightning Experience.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d193804e248">Custom URL Button or Link</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d193804e251">Lightning Experience Behavior</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Custom URL Button or Link" class="slds-cell-wrap" style="vertical-align:top;" headers="d193804e248 ">
              <p>External
                URL</p>
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>www.google.com</code></pre>
            </td>

            <td data-label="Lightning Experience Behavior" class="slds-cell-wrap" style="vertical-align:top;" headers="d193804e251 ">URL opens in new tab</td>

          </tr>
          <tr class="">
            <td data-label="Custom URL Button or Link" class="slds-cell-wrap" style="vertical-align:top;" headers="d193804e248 ">
              <p>Relative Salesforce URL,
                View</p>
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>/{!Account.Id}</code></pre>
            </td>

            <td data-label="Lightning Experience Behavior" class="slds-cell-wrap" style="vertical-align:top;" headers="d193804e251 ">Record home page opens in existing tab</td>

          </tr>
          <tr class="">
            <td data-label="Custom URL Button or Link" class="slds-cell-wrap" style="vertical-align:top;" headers="d193804e248 ">
              <p>Relative Salesforce URL,
                Edit</p>
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>/{!Account.Id}/e</code></pre>
            </td>

            <td data-label="Lightning Experience Behavior" class="slds-cell-wrap" style="vertical-align:top;" headers="d193804e251 ">Edit overlay pops up on the existing page</td>

          </tr>
          <tr class="">
            <td data-label="Custom URL Button or Link" class="slds-cell-wrap" style="vertical-align:top;" headers="d193804e248 ">
              <p>Relative Salesforce URL,
                List</p>
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>/001/o</code></pre>
            </td>

            <td data-label="Lightning Experience Behavior" class="slds-cell-wrap" style="vertical-align:top;" headers="d193804e251 ">Object home page opens in existing tab</td>

          </tr>
          <tr class="">
            <td data-label="Custom URL Button or Link" class="slds-cell-wrap" style="vertical-align:top;" headers="d193804e248 ">
              <p>$Action URL,
                View</p>
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>{!URLFOR($Action.Account.View, Account.Id)}</code></pre>
            </td>

            <td data-label="Lightning Experience Behavior" class="slds-cell-wrap" style="vertical-align:top;" headers="d193804e251 ">Record home page opens in existing tab</td>

          </tr>
          <tr class="">
            <td data-label="Custom URL Button or Link" class="slds-cell-wrap" style="vertical-align:top;" headers="d193804e248 ">
              <p>$Action URL,
                Edit</p>
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>{!URLFOR($Action.Account.Edit, Account.Id)}</code></pre>
            </td>

            <td data-label="Lightning Experience Behavior" class="slds-cell-wrap" style="vertical-align:top;" headers="d193804e251 ">Edit overlay pops up on the existing page</td>

          </tr>
        </tbody>
      </table>

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-platform-extend_click-264-0-0-production-enus/5f7d9219-b7b1-4552-8891-f1aba9b289fc/images/icon_note.png)

Note Using URL custom buttons to pass parameters to standard pages in Salesforce Classic, such as prepopulating fields when creating a record, doesn’t work in the Salesforce mobile app.

#### See Also

- [Custom Link Example: Link to Documents](https://help.salesforce.com/s/articleView?id=platform.custom_links_example_linking_to_documents.htm&release=264.0.0&type=5 "Use custom links to reference documents from a Salesforce record detail page.")
- [Custom Link Example: Link to Files in Chatter](https://help.salesforce.com/s/articleView?id=platform.custom_links_example_linking_to_files.htm&release=264.0.0&type=5 "Use custom links to reference files from Chatter.")
- [Custom Link Example: Link to Reports](https://help.salesforce.com/s/articleView?id=platform.custom_links_example_linking_to_reports.htm&release=264.0.0&type=5 "Use custom links to run reports with filtered results from a Salesforce record detail page. For example, let’s say you frequently run a mailing list report for the contacts related to an account. You can create a custom link for accounts that links directly to a report that is automatically filtered to the account that you’re viewing. In this case, your custom link must pass the account’s unique record ID to the report.")