0

I have below post install script class which is used to insert a demo login details for our application.

global class PostInstallClass implements InstallHandler {
    global void onInstall(InstallContext context) {
        if(context.previousVersion() == null) {
            ns__config__c info = new ns__config__c(); //Private Custom Setting.
            info.ns__jwtToken__c = '';
            info.Name = 'loginUserName';
            info.ns__password__c = 'Admin123';
            info.ns__eSign_Url__c = 'https://domain.ourapplication.com/';
            info.ns__domain__c = 'domain';
            insert info;
            ns__testCustom__c test = ns__testCustom__c.getOrgDefaults();//public custom setting.
            test.ns__testName__c = 'test user';
            insert test;
        }
    }
}

I did added this class to managed package POST INSTALL SCRIPT. To test if is working, I have added normal public custom setting and inserted it. Seems like it's not getting executed at all. am I missing anything?? Please help. Thank you.

1
  • pls use {} to format the code Aug 13, 2019 at 5:22

1 Answer 1

1

You are using context.previousVersion() == null it means code will execute only first installation This will not work for the Upgraded package.

If the issue is coming for the first installation then use the try-catch block and send the Mail from the catch that will the to identify the error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.