+ Start a Discussion
V100V100 

Uninstall script to remove scheduled jobs

i have created an uninstall script that looks for any scheduled jobs and then deletes them however it does not seem to be getting called as the uninstall fails as the classes have been scheduled.

 

I know the info says you cannot create scheduled jobs via the install/uninstall scripts but does not excluded removing them.

Anyone know if this is possible or not? If possible then is my code incorrect?

The custom_setting contains the scheduled job Ids and is populated correctly.

global class V100zUnInstall implements UnInstallHandler {
    global void onUnInstall(UnInstallContext context) {
    customer_setting__c b = customer_setting__c.getOrgDefaults();
    try{
        if (b.zSchJobMaster__c != '' && b.zSchJobMaster__c != null){
            system.abortJob(b.zSchJobMaster__c);
        }
    } catch (Exception e){
        // let it go b/c the job isn't scheduled
    }  
}  
}