function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Lam Ha TuanLam Ha Tuan 

How to add PostInstall script to the Package?

Hi guys! I am new to Salesforce development.
I created an Apex class that implements from the InstallHandler interface, Are there any steps else to make this class work for everytime the User install or update my Package? I already add it as an Apex class in the package but it doesn't work. Thanks so much for your help.
SwethaSwetha (Salesforce Developers) 
HI Lam,
- Are you encountering any specific error messages or issues when trying to execute the PostInstall script?

- How is the user installing or updating the package. Are they using Salesforce CLI, the Salesforce Setup UI, or a different method?

- If the package uses a namespace, ensure that the PostInstall class and its reference in the sfdx-project.json or package.xml file include the correct namespace.

Related:
https://developer.salesforce.com/docs/atlas.en-us.pkg1_dev.meta/pkg1_dev/apex_post_install_script_intro.htm

https://salesforce.stackexchange.com/questions/267443/adding-a-post-install-script-to-a-second-generation-managed-package

Thanks