You need to sign in to do that
Don't have an account?
flewells
Can Apex be used to create a custom time trigger?
I am trying to setup a workflow time trigger that will fire 1095 days (3 years) after a specified date. When I try to set this up, however, I get an error message that my number is too large.
I logged a case with Customer Support to find out the maximum # days allowed...assuming I will not be able to set this up using point and click, could Apex serve as a substitute here?
I know Apex can be used to update records immediately...can it be written to a handle time-based trigger too?
Can you think of any other way to make this work?
cool, now for the answer.
the solution will comprise of a trigger, a custom 'queue' object and scheduled apex.
the trigger will fire on insert / update of your record, and create / update a record in the custom 'queue' object. this will contain a date on which the scheduled apex should pick this record up for processing. the date will be caclulate as your record date + 1095. So this trigger will fire each time your source record is changed, thus carrying the date change to your custom queue object.
Scheduled apex, perhaps scheduled to execute just after midnight every day, will scan this table for records where the processing date meets today. then pick those records up for processing and execute your logic.
in summary, apex will execute logic depending on how /what is written.
All Answers
The scheduled apex can check everyday that the number of days elapsed is greater than the threshold and if so, process as desired.
cool, now for the answer.
the solution will comprise of a trigger, a custom 'queue' object and scheduled apex.
the trigger will fire on insert / update of your record, and create / update a record in the custom 'queue' object. this will contain a date on which the scheduled apex should pick this record up for processing. the date will be caclulate as your record date + 1095. So this trigger will fire each time your source record is changed, thus carrying the date change to your custom queue object.
Scheduled apex, perhaps scheduled to execute just after midnight every day, will scan this table for records where the processing date meets today. then pick those records up for processing and execute your logic.
in summary, apex will execute logic depending on how /what is written.