Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. /*
  2. * InstallHandler Interface by Salesforce-
  3. * InstallHandler interface only works for managed packages, as you need to select there which class to run on install
  4. * Enables custom code to run after a managed package installation or upgrade.
  5. * App developers can implement this interface to specify Apex code that runs automatically after a subscriber installs or upgrades a managed package.
  6. * This makes it possible to customize the package install or upgrade, based on details of the subscriber’s organization
  7. * 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.
  8. * If no user is specified, the install/upgrade details will be unavailable.
  9. */
  10. global class InstallHandlerInterfaceExample implements InstallHandler {
  11.  
  12. //There is only on interface method that needs to be implemented
  13. global void onInstall(InstallContext context) {
  14. insert new Account(Name = 'Install Handler Test Account');
  15.  
  16. String toAddress= 'rajat.mahajan3095@gmail.com';
  17. String[] toAddresses = new String[]{toAddress};
  18. Messaging.SingleEmailMessage mail =
  19. new Messaging.SingleEmailMessage();
  20. mail.setToAddresses(toAddresses);
  21. mail.setSenderDisplayName('Rajat\'s Package Support');
  22. mail.setSubject('Package install successful');
  23. mail.setPlainTextBody('The package had been installed successfully');
  24. Messaging.sendEmail(new Messaging.Email[] { mail });
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement