Pass timer value as a variable

I have a workflow in which one of the services make a http call to get live location details. The url is passed as a param to the service since the url can change on different implementations. The url has a get param that takes a timestamp. The timetstamp is usually a time in past since when I need the updated location. The whole workflow repeats in a fixed time interval say 5 mins. So when I run the instance now (1700 hrs), the url should be something like ‘someUrl?time=1655’ and likewise when I run the instance again at 1705, the url would be ‘someUrl?time=1700’ which consists of a static part ‘someUrl?time=’ and a variable part ‘1655’ or ‘1700’. What is the simplest way to achieve this?

Hi @sudipshocks,

welcome to the Zeebe community :tada:

Let’s see if I understand you correctly.

  • you have a workflow with a timer start event that is triggered every 5 minutes
  • the workflow contains a service task to make a HTTP call
  • the job worker read the URL from a workflow instance variable
  • the URL variable should be in the format "someUrl?time=" + time there time is now() - 5 minutes

Is this correct?

It is possible to concatenate the string in this way using an expression in the input mapping. But currently, it is not possible to access the current time from the broker in an expression.

Best regards,
Philipp

1 Like

Thank you Philipp.

The url is right now hardcoded in the workflow. Both the static part and the date time stamp.

The part rounded in red (time) should change as the time when the timer last ran (now() - 5). If this is possible, we would have one less microservice (Retrieve DateTime from Cache) to create.

Feel free to create a new issue and request the feature that you can access the current time in an expression :slight_smile:

1 Like