I have a calendar, and when I click on a day, I can schedule an event, let's say, to June 20th at 10am. So, once this day and time arrive, I want to execute an action.

My question is: How can I schedule the execution of actions to specific dates and times?

Solution

Eduardo Jauch wrote:

Hi João,

Using Timers.

https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Timers

Cheers!

Thank you!.

If I understand correctly, I can only create timers at design time, is that correct? So, in this case, since I will have multiple events, I can use the same timer and each time it is executed, change its running schedule with the variable NextRun.

In other words, if I have an event at 10am and another at 11am, I can save both in a DB entity, set the next run at 10am and once the timer runs, set the next run to 11 am, and so on... Keep updating the NextRun variable everytime the timer runs.


Hi João,

Your approach makes sense. You may want to consider having a timer that can execute more than one of your events' actions (for the cases where there are delays in execution, or overlapping events).

This article is a nice read on the topic of timer execution, and may help you come up with a consistent strategy for executing your events' actions.

As Jorge pointed, yes, it makes sense.

Just beware of the fact that the timers do not run by "user". Timers run in their own session. So, if multiple users try to set events at different or same times you may have problems.

In that case, I would run the timer at a fixed interval and every time an event must happen (from any user), trigger that event. Another approach in those cases would be to use Processes (BPT), but as they are much more complex than timers I would try to stay with the timer approach. 

Cheers.

Thank you very much for your answers!