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 Setup, click Customize, select the appropriate tab or users link, and choose 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 under the individual setup links for tasks and events. However, you can override a button that applies to both tasks and events from Setup by clicking Customize | Activities | Activity Buttons.

    For custom objects, from Setup, click Create | Objects, and select a custom object.

  2. Click New Button or Link.
  3. Enter the following attributes.
    Attribute NameDescription
    LabelText that displays on user pages for the custom button or link.
    NameThe 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 PrefixIn 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 ComponentProtected components can’t be linked to or referenced by components created in a subscriber organization. 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.
    DescriptionText that distinguishes the button or link and is displayed when an administrator is setting up buttons and links.
    Display TypeDetermines 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.

    BehaviorChoose 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 SourceTo 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.
© Copyright 2000–2014 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.