If you run into this error while making changes to an APEX class "Scheduleable class has jobs pending or in progress..." then it means that there are scheduled jobs thru the UI or thru the System.Schedule method.
Firstly, clear the existing job by running the following code:
List<CronTrigger> listCronTrigger = [select Id, CronExpression, EndTime, NextFireTime, OwnerId,
PreviousFireTime, StartTime, State, TimesTriggered, TimeZoneSidKey from CronTrigger
where State = 'Waiting' or State='Running'];
System.debug('No of jobs: '+listCronTrigger.size());
If (listCronTrigger.size() > 0)
{
for (Integer i = 0; i < listCronTrigger.size(); i++)
{
System.abortJob(listCronTrigger[i].Id);
System.debug('Job details ::'+String.valueOf(listCronTrigger[i]));
}
}
Now, try to save your APEX class and it should go thru successfully.
Firstly, clear the existing job by running the following code:
List<CronTrigger> listCronTrigger = [select Id, CronExpression, EndTime, NextFireTime, OwnerId,
PreviousFireTime, StartTime, State, TimesTriggered, TimeZoneSidKey from CronTrigger
where State = 'Waiting' or State='Running'];
System.debug('No of jobs: '+listCronTrigger.size());
If (listCronTrigger.size() > 0)
{
for (Integer i = 0; i < listCronTrigger.size(); i++)
{
System.abortJob(listCronTrigger[i].Id);
System.debug('Job details ::'+String.valueOf(listCronTrigger[i]));
}
}
Now, try to save your APEX class and it should go thru successfully.
No comments:
Post a Comment