Activity Forums Salesforce® Discussions How can you override a list button with a visuaflorce page?

  • chanchal kumar

    Member
    August 31, 2018 at 12:10 pm

    Hello Avnish,

    To override a button on a standard object:

    • Click Setup | Customize, select the name of the object, and then click Buttons and Links.
    • In the Standard Buttons and Links related list, click Override next to the name of the button you want to change.
    • Select Visualforce Page as the content type.
    • Select a Visualforce page from the content name drop-down list. Only Visualforce pages that use the standard controller for the object on which the button appears can be selected. For example, if you want to use a page to override the Edit button on accounts, the page markup must include the standardController="Account" attribute on the <apex:page> tag:

    <apex:page standardController="Account">

    ... page content here ...

    </apex:page>

    • Click Save.
  • Parul

    Member
    August 31, 2018 at 12:18 pm

    Hello Avnish,

    For overriding a related list button we have to use standard list controller. The syntex used in defining this standard list controller is same as standard controller. That is, we need not write it as standardlistcontroller in page tag, but we have to use "recordSetVar"  attribute. This variable indicates that the standard controller is a list controller. Also this variable can be used to access the selected record in related list.
    To use standard list controller define the page attribute as below (example on contact)
    <apex:page standardController="Contact" recordSetVar="LisRecs" extensions="relatedListoverideController">
    In the following example a "list button" created on contact is overridden with following visualforce page that shows the selected contact records in related list (example contact related list on a account record).

    Thanks.

  • shariq

    Member
    September 15, 2018 at 1:21 am

    Hi,

    You can override the behavior of standard buttons—like New, View, or Edit—in Salesforce Classic, Lightning Experience, and mobile independently. You can also override the tab home page that displays when a user clicks a standard, custom, or external object tab.

    But before overriding there some tips and limitations -

    • If you override a standard button in Salesforce, that button is still available in Connect Offline, but it retains its original behavior.
    • The View standard button refers to all links in Salesforce that display the detail page for a record. Overriding the View standard button reroutes all these links.
    • The View action is the only one that supports overrides with a Lightning record page. To make a Lightning record page available for a View action override, assign the page as the org default for its associated object by activating it in the Lightning App Builder.
    • If you have the View action overridden with a Visualforce page in Salesforce Classic, the Setup menu on that object record page in Lightning Experience displays the Edit Page option. Selecting Edit Page in Lightning Experience on an object page that’s overridden with a Visualforce page in Salesforce Classic lets you create a custom Lightning Experience record page for that object in the Lightning App Builder.
    • If a button isn’t available for overrides, you can still hide it on the page layout.
    • Button overrides affect everywhere that action or behavior is available. For example, overriding the New button on an account also overrides the account option in the Create New drop-down list in the Salesforce Classic sidebar.
    • Person Account records use any standard button overrides you make for accounts. Person Account records also use any overrides for the View Self-Service and Enable Self-Service buttons you make for contacts.
    • If your organization uses the Console tab, overrides for the Edit and View buttons for an object don’t affect the Edit and View buttons in the mini page layouts. Pages that display due to overrides display in the console without the header or sidebar.
    • To replace a standard button with a custom button, first define the custom button, then customize the page layout to hide the standard button and display the custom one in its place
      Because events and tasks don’t have their own tabs, you can only override their standard buttons and links.
    • When you override the Edit button with a Visualforce page, you’re also overriding default logic that checks whether the record has been locked for approval. However, you can perform the same check by implementing the Approval.lock Apex method.

    Limitations

    • You can override buttons on the detail page but not the edit page of a record.
    • You can only override these standard buttons: New, View, Edit, and Delete.
    • You can’t change buttons on lookup dialogs, reports, or tabs. However, you can change the buttons on list view and search result layouts under search layouts.
    • Action overrides on the New standard button don't work on New Object links in lookup searches.
    • You can’t relabel or relocate standard buttons on a record detail page.
    • When overriding tabs or buttons with a Lightning component, you can select only Lightning components that implement the lightning:actionOverride interface.
    • A standard button (New, Edit, View, Delete, and Clone) overridden with a Visualforce page doesn’t show up in the Salesforce app unless the Visualforce page is enabled for Salesforce mobile apps. Overriding standard list and tab controls isn’t supported in mobile.
    • When overriding tabs with a Visualforce page, you can select only Visualforce pages that use the standard list controller for that tab’s associated object, pages with a custom controller, or pages with no controller.
    • When overriding lists with a Visualforce page, you can select only Visualforce pages that use a standard list controller.
    • When overriding buttons with a Visualforce page, you can select only Visualforce pages that use the standard controller for the object on which the button appears. For example, if you want to use a page to override the Editbutton on accounts, the page markup must include the standardController="Account" attribute on the <apex:page> tag.

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos