Sample Post Install Script for a Push Upgrade
Automate the assignment of new components to existing users of a package for first- and second-generation managed packages.
Post-install scripts can be used with first and second-generation managed packages only.
For more information on writing a post-install Apex script, see Run Apex on Package Install/Upgrade.
In this sample script, the package upgrade contains new Visualforce pages and a new permission set that grants access to those pages. The script performs the following actions.
- Gets the Id of the Visualforce pages in the old version of the package
- Gets the permission sets that have access to those pages
- Gets the list of profiles associated with these permission sets
- Gets the list of users who have those profiles assigned
- Assigns the permission set in the new package to those users