Timer event that needs to start every Tuesday

Hi,
I would start timer on every Tuesday, I saw same another topic for a monthly start and there was the answer PT1M

So will it be work something like PT2D ?

Thank you!

1 Like

@philipp.ossler is the expert, but I think that duration will do every two days.

I would suggest a feel expression where you calculate the duration to the next tuesday.

Greets
Chris

Any hints on what that looks like?

Currently can’t give more input sorry. I’m not on my pc to try it out.

I can try in the evening. :slight_smile:

Correct. Use R/P7D to schedule the timer every week.

The interesting questing is how to configure the start time to run on Tuesdays.
We have an open issue that addresses the problem: Feature Request: On Timer events add scheduling at specific time · Issue #3038 · camunda/zeebe · GitHub

Nice idea :+1:

I crafted a FEEL expression to calculate the duration until the next Tuesday at 08:00:00.

(for x in 1..7 return date and time(today(),time("08:00:00Z")) + duration("P"+string(x)+"D"))[day of week(item) = "Tuesday"][1] - now()

You could use the expression for a timer in the workflow and then loop back to the timer to wait until the next Tuesday. Or, use it in front of the cycle timer that runs every 7 days.

In more detail:

  • create a list of data-time values for the next 7 days and set the time to 08:00:00
for x in 1..7 return date and time(today(),time("08:00:00Z")) + duration("P"+string(x)+"D")
//  List(2020-12-19T08:00Z, 2020-12-20T08:00Z, 2020-12-21T08:00Z, 2020-12-22T08:00Z, 2020-12-23T08:00Z, 2020-12-24T08:00Z, 2020-12-25T08:00Z)
  • filter the list by a date-time on Tuesday
(for x in 1..7 return date and time(today(),time("08:00:00Z")) + duration("P"+string(x)+"D"))[day of week(item) = "Tuesday"]
//  List(2020-12-22T08:00Z)
  • return the only element of the list
(for x in 1..7 return date and time(today(),time("08:00:00Z")) + duration("P"+string(x)+"D"))[day of week(item) = "Tuesday"][1]
//  2020-12-22T08:00Z
  • calculate the duration between the date-time and now
(for x in 1..7 return date and time(today(),time("08:00:00Z")) + duration("P"+string(x)+"D"))[day of week(item) = "Tuesday"][1] - now()
//  PT81H55M39.422615S

Does this help you?

4 Likes

Hi, Thanks for your answers!

Could you recommend me some environment to test and debug the similar expressions? Maybe some online editor?
Thanks!

The easiest way to test FEEL expressions is the FEEL REPL. See here: https://github.com/camunda/feel-scala#feel-repl