function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Liron CohenLiron Cohen 

Cannot delete class from production

hi.
I'm trying to delete class from production. 
Tried with eclipse/workbench and failed, then tried with ant and received error: "This apex class is referenced elsewhere in salesforce.com. Remove the usage and try again. : Scheduled Jobs - 08e2400000232Sb. This Schedulable class is in use. : Apex Class."

Tried to find this schedule job, but it is not available probably old and already deleted. 
I read in some other post that in such case I need to log a case to SF support to delete this job, but when I go to Cases page on topic for deployment I get the message: "Developer support for standard customers and partners is supported directly through our community. If you have a developer support question, please click here"

So how I'm supposed to open a case? 
Is there any other option to delete this apex job without support?

Please don't suggest to wait a week until jobs being cleaned by SF automatically, I tried this deleting process also month ago and received the same error.

Thanks.
Liron
v varaprasadv varaprasad
Hi Liron,

Please execute the following code in the developer console.if you know id you can use  1st one else using the class name 2nd method you abort the job.
 
abortJob(jobId)
Stops the specified job. The stopped job is still visible in the job queue in the Salesforce user interface.
1.  We need to execute following code in developer console to abort single job.
         EX :   System.abortJob (“003j000000QQHjr”);

2.  We need to execute following code in console to stop multiple jobs.

Id ids = [SELECT id, name FROM ApexClass WHERE Name = 'AccountUpdate'].id;

List<AsyncApexJob> jobs = [SELECT Id, ApexClassId, Status FROM AsyncApexJob WHERE ApexClassId =: ids AND Status IN ('holding','Queued','Preparing')];
System. Debug ('jobsjobsjobsjobsjobs ‘+jobs);
For (AsyncApexJob job: jobs) {
    System.abortJob (job. ID);

}

 

Hope this helps you!

Thanks
Varaprasad
For Support: varaprasad4sfdc@gmail.com
 
Liron CohenLiron Cohen
Hi Varaprasad,
Actually I already tried this, but just to make sure I tried again now, and receive the message:
"Line: 1, Column: 1.
System.StringException: Job does not exist or is already aborted."

+Getting the same error during deletion for ant.

 
v varaprasadv varaprasad
Id ids = [SELECT id, name FROM ApexClass WHERE Name = 'AccountUpdate'].id;

List<AsyncApexJob> jobs = [SELECT Id, ApexClassId, Status FROM AsyncApexJob WHERE ApexClassId =: ids AND Status IN ('holding','Queued','Preparing')];
System. Debug ('jobsjobsjobsjobsjobs ‘+jobs);
For (AsyncApexJob job: jobs) {
    System.abortJob (job. ID);

}

Change class name  AccountUpdate to your class name and try once.

 
Liron CohenLiron Cohen
Hi.
Same error after running this script for the my class. 

I also saw in the debug log, that no jobs were retrieved from running this script


Id ids = [SELECT id, name FROM ApexClass WHERE Name = 'ScheduleBatchDelTempClaim'].id;

List<AsyncApexJob> jobs = [SELECT Id, ApexClassId, Status FROM AsyncApexJob WHERE ApexClassId =: ids AND Status IN ('holding','Queued','Preparing')];
System. Debug ('jobsjobsjobsjobsjobs ‘+jobs);
For (AsyncApexJob job: jobs) {
    System.abortJob (job. ID);

}