I'm developing an app for the appexchange containing custom visualforce pages/components.

Instead of asking the user to create custom fields and edit layouts to place the vf pages after the installation, I would like to automate the process.

I know there is the post-install script to do it, but my question is "How to do it"?

What I want is to update existing layouts, like the Accounts one, in order to add a section without overriding the whole layout. i don't want the user to lose the way they edited their layouts.

I am new to salesforce , please guide me.

  • 2
    You could do so, but I would advise against it. Such automation might not be what the administrators want. For example, maybe they have multiple layouts, and they only want it on a few or just one. Or, maybe they want them in a different area than some arbitrary location. Instead, I would suggest you provide a Configuration link that has a Visualforce page allowing them to easily modify whichever layouts they prefer. There are examples of this here on SFSE.
    – sfdcfox
    Commented Jan 19, 2017 at 5:10
  • Okay , if we do that , can you help me with the process of doing so. I am unable to find the examples link , could you paste the url or link in the comment
    – Abi
    Commented Jan 19, 2017 at 6:38
  • salesforce.stackexchange.com/questions/25139 Something like this might help...
    – sfdcfox
    Commented Jan 19, 2017 at 6:55

1 Answer 1


A viewpoint we often miss when focussed on our own app, is that our app may well be installed in an org that has many other apps installed and lots of local customisation.

The SObjects that apps tend to share - such as Account and Contact - are particularly likely to have had fields and layouts and record types added. So automating the process of merging the changes we want into what is already there in an exact way is impossible: the software can't know the intent behind the existing configuration.

The SObjects that our app defines are potentially a simpler case and so a better case for automation. Though for the domain I work in customers want to add fields and change layouts there too.

The metadata API lets you write tooling (including in Apex) to do the updates. But that tooling would be complex as it would need to be interactive to deal with conflicts and user choices. If you and your app are new to Salesforce, your effort is probably better directed towards app features than this sort of tooling. (There may be 3rd party tools already written that could be leveraged.)

For our apps, we provide "deployment tasks": instructions to Salesforce administrators on what to do manually after the app is installed or upgraded in the form of documentation. Far from ideal, but it is a pragmatic solution.

You must log in to answer this question.

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