How do I run postinstallscript from anonymous window to check if it is working or not?

I am trying to install a package to another org where it is failing with below error.

Unexpected Error The package installation failed. Please provide the following information to the publisher: Organization Name: prime.com Organization ID: 00D6F000001GQCU Package: accpack Version: 1.0 Error Message: The post install script failed.


Created a custom field on contact object. Now I am trying to package and trying to install into another org.

In my post install script I am trying to assign this custom field to contact page layout in the installed org where it is failing.

Please help me on this.

  • Apparently, if you specify an Apex Exception user for your package, you should get the error by email. Have you set this value? Did you get an email? You can't run a script like that in execute anonymous, you'd have to use a unit test. Did you write a unit test for it and verify?
    – sfdcfox
    Commented Nov 28, 2018 at 8:08
  • 1
    it will be also wise to check following quesions to see all hidden "gems" of post install process -- salesforce.stackexchange.com/questions/32607/…
    – kurunve
    Commented Nov 28, 2018 at 8:10
  • @sfdcfox -- Yeah, written the test class and its working fine .. but when I am trying to install to other org its failing Commented Nov 28, 2018 at 8:13
  • @jayakrishna did you check your email for a log file? Did you configure this setting? Is this a "real" org you're testing in, or a Sandbox? If you want, you can post your code here (if you can), it may help us help you identify the problem.
    – sfdcfox
    Commented Nov 28, 2018 at 8:17
  • @sfdcfox -- it is my trail org .. can you please let me know how can I configure this Commented Nov 28, 2018 at 8:19

1 Answer 1


You should get emails from package installs or upgrades, if subscriber didn't set Email Deliverability to No email. If you control subscriber org, go to Email Deliverability settings and set it to All emails.

Then you should be able to email the Email Stack Trace to yourself

public inherited sharing class InstallHandler implements System.InstallHandler {
    public void onInstall(InstallContext context) {
        try {
        } catch (Exception e) {
                'Installation Failure' + context.organizationId(),
                ' e: ' + e.getMessage() + ' stack trace ' + e.getStackTraceString()
  • I have noticed that I don't get emails from sandboxes or scratch orgs, but email deliverability from DE orgs works fine
    – Patlatus
    Commented Mar 16, 2023 at 10:34

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .