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
Ram ChaturvediRam Chaturvedi 

DML operation DELETE not allowed on CronTrigger ?

String JobName = 'job8'+recId;
           
           
           
            CronTrigger cjd = [SELECT Id FROM CronTrigger where CronJobDetail.Name=:jobname];
            if(cjd!=null){
           
                delete cjd;
           
            }

how can we delete schedule job ?
AshwaniAshwani
You can not delete Cron trigger.

You can abort job by

System.abortJob(cjd.id)l


Ankit AroraAnkit Arora
You've to abort the job like this :


  system.abortJob(cjd);
Deepak Kumar ShyoranDeepak Kumar Shyoran
If you want to abort a Schedule job the use use below method and  pass job Id which you want to abort.

 system.abortJob(jobIdYouWantToAbort);