Batch and Schedule apex jobs aborting using
system.abortJob
abortJob(jobId)
Stops
the specified job. The stopped job is still visible in the job queue in
the Salesforce user interface.
Signature
System.abortJob(String jobId)
Parameters
jobId
Ø
We need to execute following code in developer
console to abort single job.
EX : System.abortJob (“003j000000QQHjr”);
Ø 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);
}
=============================================================
No comments:
Post a Comment