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:
And here's a screenshot of what the schedule looks like:
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){
contactIds.add(c.Id);
}
if( contactIds!=null) DonorLevel.set(contactIds);
}
}
Any idea what's going on or how to fix this? Thanks in advance!
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