Siddhartha Gutha
Siddhartha Gutha

Reputation: 72

Is there a way a method can be triggered or run during a salesforce package installation process?

I would want to do this to run post installation setup process like adding custom data that is required for the application to run.

One option I am aware of is to Write Installation and Setup instructions for users. Create visualforce page and include a button on this page. Redirect user to this page as the process of Installation and ask the user to click the button.

I only wanted to know If there was a more elegant way to solve the problem and if there is a way to call a method during the installation process.

Upvotes: 1

Views: 544

Answers (3)

cjohn
cjohn

Reputation: 61

Salesforce has recently implemented the ability to execute scripts (as Apex) during package Install / Uninstall: http://www.salesforce.com/us/developer/docs/apexcode/Content/apex_install_handler.htm

Upvotes: 6

pbattisson
pbattisson

Reputation: 1240

My question would be revolving around why you need custom data for the app to run? One of the things Salesforce look for when doing a security review of your code and the unit tests you have is to check to see if you are requiring data in your org as this is bad practice. Note that if your app is requiring specific data to run then it cannot be tested properly as the data will not be in the org when running the tests on install.

What is the data you are requiring? Could it be stored in an xml like static resource file or something similar for you to load and parse as it is needed?

Paul

Upvotes: 1

Abhinav Gupta
Abhinav Gupta

Reputation: 207

No, we can't have a post installation script for the app. What you are saying is best solution, just keep a custom setting to flag, if initial setup is not done, then redirect to the setup page first, other wise do the normal work.

Upvotes: 1

Related Questions