Timer should send mail stating when it will next run
Question
Application Type
Service

I have a timer that generates keys for a particular API, and sends mail to appropriate lists when it runs.

I would like this timer to be able to include a statement about its next run time in the mail.

Timers have a property called NextRun, but that property isn't set while the timer is running, so my mail currently says something like, "this will happen again on <timestamp>", and it sets that timestamp to the current time. This is not useful.

How can I get this to work? 

Champion

Hi Adina,

You can calculate the next time according to the schedule you set to run the timer.

Kind regards,




The timer's Schedule currently says "12:30 1st Mon". I would rather not write a parser to interpret that, and then write something to compute dates. 

mvp_badge
MVP

Hi Adina, 

You are right that is not the way to go. 

OutSystems already calculates the next run date for you so you don't have to do that yourself. Please check the reply I have before. You can find the value in entity ossys_Cyclic_Job, and it is already in date time format.


Next_Run
The date and time of the next execution (using the database clock).
The Scheduler Service executes Timers which have Next_Run <= current date time.
mvp_badge
MVP

Hi Adina,

Please read the document Platform Timers And Asynchronous Processes on how to get the Next_Run property from the ossys_Cyclic_Job  entity, that is used by the OutSystems scheduler to determine the next run of a timer

If you have your timer coded in the same Traditional Web End User module as your Email screen, then use the Send Email widget directly in the timer action.

If you have your timer coded in a core module, or in a reactive web module, you need to do some extra work, the easiest is to use the following Forge component Mail Extended to use an email from an end-user module without having upward references from your module with the timer logic.

Some  very good articles with detailed information on how timers execute and how to write safe timers from my fellow MVP's ,  I would suggest reading:

Regards,

Daniel

I understand all the answers, and the "next_run" is indeed the property to check. But are you all sure that the "next_run" is filled during the timer itself? I would expect not, and it is exactly what Adina is asking as well. (Adina even clearly mentioned the "next_run" property in the original question) 

mvp_badge
MVP

This is how it works:

  1. The Scheduler checks timers to run on the database
  2. Evaluate the NEXT_RUN value against the current date
  3. Locks the Timers data model and update the timer status to RUNNING
  4. This lock allows multiple OutSystems Schedulers to concurrently access the same table, without running the same timer at the same time in different Front-Ends
  5. Executes timer with a local Web Service Request
  6. Upon completion, if there’s a schedule, redefines the NEXT RUN value

More details here: https://success.outsystems.com/Support/Enterprise_Customers/Maintenance_and_Operations/OutSystems_Platform_Timers_and_Asynchronous_Processes

It's the scheduler, not the timer, that sets the NEXT RUN value.


Exactly, so all the answers are not really answering the question. (except for Tom's)

If you need the next run value inside the timer, you'll have to calculate it yourself.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.