1

Is there a way to add a custom button on a page layout automatically on installation of the package?

I already created the custom button in the Account's object and added to the installation package. If I install my package now, I have to manually add the custom button to the page layout by editing the layout, and drag and drop it on the page.

enter image description here

1
  • Since this is on the account object, I'm assuming that you wouldn't be able to deploy an entire page layout.
    – martin
    Feb 15, 2016 at 10:58

3 Answers 3

1

The Metadata API has the capability and this existing answer Can we create custom buttons on the objects through code shows how to do it trough Apex code. (Note that the API has got simpler since that post - see Apex Wrapper Salesforce Metadata API - so the polling is I think no longer needed).

Your target org may have many Account layouts and it may not be appropriate to have the button on all of them. So I suggest that while you could automate the addition of the button, giving your customers the choice by not automating and instead giving them instructions for the manual addition of the button may be the more appropriate approach.

0

You have two choices:

1) Have the admin add the button.

2) Write a custom Java/Flash page that the administrator can use to do this automatically.

0

You need to add the button on the Page Layout before creating the package.Now commit the page layout and create a package.

Now when you install this package then button is available on the page layout. Hope this helps.

1
  • Layouts like Account are often customised and there may be many Account layouts so forcing users to only use the one supplied in the package will often not be appropriate.
    – Keith C
    Feb 15, 2016 at 11:38

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .