I have an install script in a managed package which inserts 2 records in the installing org. This seems to be working fine. I figured that as a part of uninstall, I should be deleting these records from the uninstalling org, and so I made an uninstall Handler class in which I query for these records and delete them. I have put them in a try/ catch.

However, when I uninstall the package, the uninstall fails (and it is probably because of this uninstall class). So I go to the uninstall class in the org where the package is installed ( click on edit and then click on cancel) and after doing this step, I am able to uninstall the package successfully ( I don't know if this is a Salesforce bug ) but the uninstall script doesn't delete the records that it is supposed to. The records still exist in the org where this is uninstalled.

If there is no uninstall class specified, then the package uninstalls successfully, but I need the uninstall class to delete those records that are inserted as a part of the install. Please help!!

1 Answer 1


I just tested 2 more cases :

  1. where I try to insert records and delete records. During uninstall, it does give me the error 'uninstall failed' so I go to the class, click edit and cancel and then successfully uninstall. And I see that as a part of the uninstall, the records I inserted do infact insert, but the ones I specified to delete, do not.

  2. I try to only insert records in the uninstall script. During uninstall, I am successfully able to uninstall and the record does insert.

So, we cannot delete records in an uninstall script in a managed package, neither should we include delete records in the uninstall script, otherwise it will result in uninstallation failed, and having to workaround with 'Edit and Cancel'.

I haven't found it to be mentioned anywhere in the documentation provided by Salesforce.

You must log in to answer this question.

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