Documentation Version
Winter '16 (API version 35.0)
  • Winter '16 (API version 35.0) 35.0
  • Summer '15 (API version 34.0) 34.0
  • Spring '15 (API version 33.0) 33.0
  • Winter '15 (API version 32.0) 32.0
  • Summer '14 (API version 31.0) 31.0
  • Spring '14 (API version 30.0) 30.0
  • Winter '14 (API version 29.0) 29.0
  • English

Defining Custom Buttons and Links for Visualforce

Before creating a custom button or link, determine what action you want to occur when a user clicks it.

  1. From the management settings for the appropriate object, go to Buttons, Links, and Actions. Custom buttons are not available on the user object or custom home pages.

    Custom buttons and links are available for activities in the object management settings for tasks and events. However, you can override a button that applies to both tasks and events from the object management settings for activities.

  2. Click the button for creating a new button or link.
  3. Enter the following attributes.
    Attribute Name Description
    Label Text that displays on user pages for the custom button or link.
    Name The unique name for the button or link used when referenced from a merge field.This name can contain only underscores and alphanumeric characters, and must be unique in your organization. It must begin with a letter, not include spaces, not end with an underscore, and not contain two consecutive underscores.
    Namespace Prefix In a packaging context, a namespace prefix is a one to 15-character alphanumeric identifier that distinguishes your package and its contents from packages of other developers on AppExchange. Namespace prefixes are case-insensitive. For example, ABC and abc are not recognized as unique. Your namespace prefix must be globally unique across all Salesforce organizations. It keeps your managed package under your control exclusively.
    Protected Component Protected components can’t be linked to or referenced by components created in a subscriber org. A developer can delete a protected component in a future release without worrying about failing installations. However, once a component is marked as unprotected and is released globally, the developer can’t delete it.
    Description Text that distinguishes the button or link and is displayed when an administrator is setting up buttons and links.
    Display Type Determines where the button or link is available on page layouts.
    Detail Page Link
    Select this option to add the link to the Custom Links section of your page layouts.
    Detail Page Button
    Select this option to add the custom button to a record’s detail page. You can add detail page buttons to the Button section of a page layout only.
    List Button
    Select this option to add the custom button to a list view, search result layout, or related list. You can add list buttons to the Related List section of a page layout or the List View and Search Result layouts only.

    For list buttons, Salesforce automatically selects a Display Checkboxes (for Multi-Record Selection) option that includes a checkbox next to each record in the list, allowing users to select the records they want applied to the action on the list button. Deselect this option if your custom button does not require the user to select records. For example, a button that navigates to another page.

    Behavior Choose the outcome of clicking the button or link.

    When applicable, some settings have default values. For example, if you choose Display in new window, the default height of a new window is 600 pixels.

    Content Source To use a Visualforce page, select “Visualforce Page,” and choose the page from the drop-down list. Visualforce pages cannot be used as custom links on the home page.
  4. Click Save when you are finished.

    Click Quick Save to save and continue editing.

    To view the specified URL, click Preview.

    To quit without saving your content, click Cancel.

  5. Edit the page layout for the appropriate tab or search layout to display the new button or link.

    If you add a custom link for users, it is automatically added to the Custom Links section of the user detail page. Detail page buttons can be added to the Button section of a page layout only.

  6. Optionally, set the window properties to open the button or link using settings other than the user’s default browser settings.