Problem delay timer process

Good afternoon

We have a problem with the delay of a start timer, the timer has to run every X minutes (set to a constant).
We have created a rule to delay us so that the process runs at the exact minute.
For example, if it's 6:26 p.m. and we run every 15 minutes and publish right now, what we want is to set a 4-minute delay so that the process doesn't start until 6:30 p.m.

The problem is that the process is not starting and we do not know what we are doing wrong.

The code:

load(
local!intervalos: (
60 / ri!duracion
) + 1,
local!enumeration: enumerate(
local!intervalos
),
local!intervalosFinal: a!forEach(
local!enumeration,
fv!item * ri!duracion
),
local!retardo: reject(
fn!isnull,
a!forEach(
local!intervalosFinal,
if(
and(
minute(
local(
now()
)
) > fv!item,
minute(
local(
now()
)
) < local!intervalosFinal[fv!index + 1]
),
local!intervalosFinal[fv!index + 1] - minute(
local(
now()
)
),
null
)
)
),
if(
or(
isnull(
local!retardo
),
local!retardo = "",
length(
local!retardo
) < 1
),
0,
local!retardo[1]
)
)

Do you know what the problem may be?

A greeting and thanks in advance

  Discussion posts and replies are publicly visible

  • Is it necessary to use the "Delay for..." option? I would think it would be a lot easier to use the second radio button to "Delay until the date and time specified by this expression". Then if you define the expression to return midnight or noon (or really anything that is exactly on the 15 minute time interval) then it should work fine.

  • Good Peter,
    We do the delay because in addition to what was commented, the batch must be executed from 9: AM to 9: PM every 15 minutes, so if the process is published in an intermediate interval, let's imagine that it is published at 9:13 AM. we want it to not run until 9:15.

    So what we had thought is to calculate the delay that we would have to enter and do it, the rule that I attach separately works correctly but when putting it in the timer it does nothing.

    This way it doesn't do anything either

    Any idea what we are doing wrong?

    A greeting and thanks in advance

  • Ok so if you want to ensure that your batches are executed every 15 minutes starting precisely at 9AM, here's what I would do:

    1) Use a rule in the delay expression that uses time as a decimal to find the closest 15 minute period. I would do something like this:

    todatetime((round(todecimal(now())*24*4,0)+1) / 24/4)

    Basically what this does is it converts the current date and time to a decimal and then rounds the decimal to the nearest 15 minute period.

    2) In the timer recurrence don't use a complex expression - just run it every 15 minutes (maybe store 15 in a constant?)

    3) Set up your process so that there is a gateway immediately after the start node. In that gateway, check to see if the current time is between 9AM and 9PM.

    If you do it this way, then your process will always start every 15 minutes, but it will only continue to the actual process logic if it's between those times. I prefer this rather than complex logic in the timer because it's a lot easier to debug, and there's not really a downside if your process just starts and immediately goes to the end not if it isn't in the right hours during the day.

  • Good Peter,

    Thank you very much for your contribution, I understand what you want to tell me.
    Only one doubt, of the rule you put is that I have seen that if for example it is 11:54 it tells you that the next interval to execute would be 12:15, if instead you execute it at 12:51 for example it tells you It would be 12:00 but if you execute 11:54, what I am telling you would happen, then if for example we publish our process at 11:54 it will skip the 12:00 interval and it will go directly to 12:15.
    Do you know why it can be?

    Thank you very much for your help!

  • Ahhh I know what the problem is - confusingly the decimal representation of time is actually a negative number, so instead of just rounding to 0, you actually have to round up to get the correct result. Try this one:

    todatetime((roundup(todecimal(now())*24*4,0)+1) / 24/4)

  • Good morning Peter,

    Just yesterday I began to test that option, but I did not want to write until I did all the tests but effectively with that solution it works correctly.

    Thank you very much for your help!!