function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Derek BrostDerek Brost 

Is it possible to schedule apex to run along with a trigger?

We have an APEX trigger that is set to run to update the number of cases an account has had in the past 30/60/90 days. It works great the only issue is that it only runs when we update the account. In some cases this is very few and far between cases so numbers can get out dated. 

We tied to write the trigger to work on the case level, but that broke a few things. 

Just wondering if there are any suggestions or ideas on what we could to to automate this process more. 

Thanks, 

Derek
Veena Sundara-HeraguVeena Sundara-Heragu
Since you want the numbers based on the current date, you could have a scheduled job runs early every morning that will process every account in your instance and update the numbers.

Since the number of accounts can get very large, it would be best to have the scheduled class call a batch class to do the processing.