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
Vishnu VaishnavVishnu Vaishnav 

Post Install Script is not running after installing package...

Code is here :

global without sharing class PostInstallClass implements InstallHandler {
    global void onInstall(InstallContext context) {    
               
        User u = [Select Id, Email,name from User where Id =:context.installerID()];   
        List<String> toAddresses = new list<String>();
        toAddresses.add(u.Email);        
        Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        mail.setReplyTo('vishnukumarramawat@gmail.com');
        mail.setSenderDisplayName('My Package Support');
        mail.setSubject('Package install successful');
        mail.setPlainTextBody('Thanks for installing the package.');
        Messaging.sendEmail(new Messaging.Email[] { mail });
        
        //Send mail to developer whenever new user install it
        toAddresses = new list<String>();
        toAddresses.add('vishnukumarramawat@gmail.com');        
        mail = new Messaging.SingleEmailMessage();
        mail.setToAddresses(toAddresses);
        mail.setReplyTo(u.Email);
        mail.setSenderDisplayName('Twins Package installed');
        mail.setSubject('New user install successful');
        mail.setPlainTextBody('Username : '+u.name + '\n' +'Email : ' + u.email);
        Messaging.sendEmail(new Messaging.Email[] { mail });
    }   
}
Best Answer chosen by Vishnu Vaishnav
Dushyant SonwarDushyant Sonwar
Hi Vishnu,
when incorporating a post install script using the InstallHandler interface, remember to specify its class name in the Post Install Script field in the Package Detail before you upload the package.
User-added image

Hope this helps.

All Answers

Dushyant SonwarDushyant Sonwar
Hi Vishnu,
when incorporating a post install script using the InstallHandler interface, remember to specify its class name in the Post Install Script field in the Package Detail before you upload the package.
User-added image

Hope this helps.
This was selected as the best answer
Dushyant SonwarDushyant Sonwar
Glad, I could help :)
tarun jain 110tarun jain 110
How to deploy manged packaged on app exchange please provide the steps