Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * InstallHandler Interface by Salesforce-
- * InstallHandler interface only works for managed packages, as you need to select there which class to run on install
- * Enables custom code to run after a managed package installation or upgrade.
- * App developers can implement this interface to specify Apex code that runs automatically after a subscriber installs or upgrades a managed package.
- * This makes it possible to customize the package install or upgrade, based on details of the subscriber’s organization
- * If the script fails, the install/upgrade is aborted. Any errors in the script are emailed to the user specified in the Notify on Apex Error field of the package.
- * If no user is specified, the install/upgrade details will be unavailable.
- */
- global class InstallHandlerInterfaceExample implements InstallHandler {
- //There is only on interface method that needs to be implemented
- global void onInstall(InstallContext context) {
- insert new Account(Name = 'Install Handler Test Account');
- String toAddress= 'rajat.mahajan3095@gmail.com';
- String[] toAddresses = new String[]{toAddress};
- Messaging.SingleEmailMessage mail =
- new Messaging.SingleEmailMessage();
- mail.setToAddresses(toAddresses);
- mail.setSenderDisplayName('Rajat\'s Package Support');
- mail.setSubject('Package install successful');
- mail.setPlainTextBody('The package had been installed successfully');
- Messaging.sendEmail(new Messaging.Email[] { mail });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement