Skip to content

Instantly share code, notes, and snippets.

@cdeckert
Last active December 26, 2015 03:09
Show Gist options
  • Save cdeckert/7083499 to your computer and use it in GitHub Desktop.
Save cdeckert/7083499 to your computer and use it in GitHub Desktop.
Stop all scheduled jobs in Salesforce
List<CronTrigger> listCronTrigger = [SELECT Id, CronExpression, EndTime, NextFireTime, OwnerId,
PreviousFireTime, StartTime, State, TimesTriggered, TimeZoneSidKey FROM CronTrigger
WHERE State != 'DELETED'];
System.debug('#### Number of jobs: '+listCronTrigger.size());
if (listCronTrigger.size() > 0)
{
for (CronTrigger aCronTrigger : listCronTrigger)
{
System.abortJob(aCronTrigger.Id);
System.debug('#### deleted Job details :' + String.valueOf(aCronTrigger));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment