1

I am developing one app, some of my customers getting one problem while uninstalling the app, getting a random error saying that can't uninstall [app name]. this is being caused by on orphaned cron script. for this every time we have to file a case with them asking them to run a script to allow the customer to delete the job. below is the script I need to run while uninstalling the package

for (CronTrigger ct : [select id from crontrigger where state = 'Deleted']){system.abortJob(ct.id);}

Is there any way we can have an uninstall script as part of the managed package?

2 Answers 2

1

You can have an uninstall script that implements UnInstallHandler as part of a managed package. But you can't prevent that cron error with it. The script runs after the uninstall transaction.

enter image description here

Maybe if you have an existing configuration screen, you could funnel the user into that in lieu of the uninstall button. Then abort any scheduled jobs or batches guaranteed to impede the uninstall?

0

You have to manually remove all the components that make reference of something in your package. That means you have to abort and exclude the job before you uninstall your package.

Source: have the same problem. I need to delete some workflow rules that reference fields and record types inside a managed package before uninstalling it. I tested this, and can confirm that this is true to classes as well.

You must log in to answer this question.

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