I have a custom object called Lease_Reminder. The object has a couple of fields on it, including Status_Alert and Effective_Date. As today gets closer to the Effective_Date, the Status_Alert needs to change to a more urgent status (where 0 is least urgent and 5 is most urgent).

I'm using this as roll-up field for a parent object, so I can't just use a formula.

Urgency occurs in three-month increments, so if, for example, the Lease_Effective date is 12/1/2015 and today is 6/1/2015, the Status_Alert would change to, say 3; but it doesn't need to change to 4 until 9/1/2015.

I need to run the scheduler class on a daily basis.

My question is: Should I add another field called Next_Status_Update so that when I run the query for the scheduler class I only select Lease_Reminders where Next_Status_Update = today? Or is it equally efficient to just run the scheduler class on all of the Lease_Reminder records and update the Status_Alert as needed based using conditional logic based upon today's date.

I hope this makes sense. Thanks in advance for any assistance you can give me.


1 Answer 1


Personally I would not add an extra field but rather query to find the Lease_Reminder objects to update i.e. match on the date and on the wrong status so you only update the status values you need to. That then allows the code to be run more than once on any day (e.g. if errors have occurred). Also write the code so you can pass in a date so you can re-run manually (e.g. from the Developer Console) if a day gets missed or fails. Or don't code to the absolute day but code to fix earlier days if they have not already been processed.

Adding an extra field amounts to a duplication of information: you then face the possibility that the two versions of the information can get in an inconsistent state and make the problem more confusing.


You must log in to answer this question.

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