I've created a scheduled Apex class to calculate the donor level (think 'gold', 'platinum', 'bronze', etc.) for a contact based on the amount donated. The class is fired by a trigger when new donations are added and also must be fired as payments older than one year are no longer applied toward the contact's donor level.

The trigger works great but the schedule does not.

Here's a screenshot of the the job stuck in the "queued" status: Job is stuck in "queued" status

And here's a screenshot of what the schedule looks like: Job schedule

Finally here's the schedulable class:

global class DonorLevelSchedule implements Schedulable {

     global void execute(SchedulableContext sc) {

          list<Contact> contacts = new list<Contact>([select Id from Contact where Earliest_Eligible_Donation_Date__c < LAST_N_DAYS:365 ]);

          set<Id> contactIds = new set<Id>();

          for( contact c : contacts){

          if( contactIds!=null) DonorLevel.set(contactIds);



Any idea what's going on or how to fix this? Thanks in advance!


  • *I should have mentioned that the class is not firing; I have some test data that should have been updated by this class and so far nothing. Sep 21, 2014 at 18:37
  • Can you run a SOQL query against CronTrigger to check the CronExpression and add the results to the question? Example query: Select Id,CronJobDetailId,NextFireTime,PreviousFireTime,State,StartTime,EndTime,CronExpression,TimeZoneSidKey,OwnerId,TimesTriggered from CronTrigger Sep 22, 2014 at 0:42
  • Assuming I've used the UI to create the schedule, what would the job ID be? Also: is there a good source of online documentation for scheduling Apex? What I've found so far is confusing and inadequate. Sep 22, 2014 at 14:42

1 Answer 1


I can think of two things you can try:

  1. Change the definition of your list (you are declaring a new List with the static SOQL in the constructor). While I'm not sure if that is a problem or not, I do know that normally, this would be written:

    list<Contact> contacts = [select Id from Contact where Earliest_Eligible_Donation_Date__c < LAST_N_DAYS:365 ];
  2. You will get more control over your schedule if you use the API to create a schedule. Try this:

    MyScheduler scheduler = new MyScheduler();
    String sch = '0 0 12 * * ?';
    system.schedule('My Scheduler', sch, o); 
  • Where would I put the system.schedule(); code? Is this something I should do from the execute anonymous window? Or if I put it in its own class, when will the code to create the schedule be executed? Thanks for pointing out the unnecessary stuff in my list declaration derp. Can you recommend a good online source for scheduling Apex? The documentation I've found is confusing an inadequate. Sep 22, 2014 at 14:46
  • Update: I've created the schedule using the API by putting this into the execute anonymous window: DonorLevelSchedule dl = new DonorLevelSchedule(); string sch = '0 0 11 * * ?'; system.schedule('Donor Level Update', sch, dl ); At Jobs > Scheduled Jobs, I can see the job is there and that it started at 11:00 am as expected. However, if I go to Jobs > Apex Jobs, the status is still stuck in "Queued". Sep 22, 2014 at 16:09
  • Check this answer: salesforce.stackexchange.com/questions/15003/… - Looks like it's supposed to be 'Queued' as it doesn't have an end date. Check your data to see if it ran. Sep 22, 2014 at 17:47
  • Thanks for your help! I'm afraid the error was elsewhere and due to my own sloppiness, however, using system.schedule to set the schedule up proved to be much more useful than using the UI. Thanks again! Sep 22, 2014 at 18:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .