If you are a non-profit running the Convio CommonGround application on the Salesforce.com platform, you may have noticed something that I think is an oversight by Convio. One of the nice things is that for contacts and accounts you have a number of fields that show lifetime, last, ytd, largest, etc… giving.
Convio provides two utilities that an administrator can click a button and force the re-calculation of these values or a staff person can force the re-calculation on an individual record. Our questions to Convio have been returned that these values do not get updated unless buttons are clicked! Why does human intervention need to be required to update these formula fields? This seems terribly onerous on staff and provides a liability by allowing reporting on values that are not in fact accurate if the re-calculations have not be run recently by hand.
To address this, we created an Apex class that we use to schedule the automatic execution of the recalculation utilities nightly. This ensures that these summary fields are always accurate within 24 hrs of any data being updated. Now, I am including a sample Apex class here, but this is not a how-to type of post. I’m merely providing a possible solution to the problem. Your mileage may vary. If Apex development is foreign to you, get a consultant/developer.
/*
To Run:
AccountGiftSummaryBatchScheduler scheduler = new AccountGiftSummaryBatchScheduler();
String scheduleString = '0 0 23 * * ?';
String jobId = System.schedule('AccountGiftSummaryBatch', scheduleString, scheduler);
To Check Status:
CronTrigger ct = [SELECT id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
*/
global class AccountGiftSummaryBatchScheduler implements Schedulable {
global void execute(SchedulableContext sc) {
cv.AccountGiftSummaryBatch job = new cv.AccountGiftSummaryBatch();
Database.executebatch(job, 100);
}
static testmethod void test() {
Test.startTest();
String jobId = System.schedule('AccountGiftSummaryBatchScheduler', '0 0 23 * * ?', new AccountGiftSummaryBatchScheduler());
CronTrigger ct = [SELECT id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
System.assertEquals('0 0 23 * * ?', ct.CronExpression);
System.assertEquals(0, ct.TimesTriggered);
System.debug('*************************** ' + ct.NextFireTime);
//System.assertEquals('2022-09-03 00:00:00', String.valueOf(ct.NextFireTime));
Test.stopTest();
}
}
Popularity: 1% [?]