Preserving state on a workflow

I have a requirement where i need to implement a workflow that will send a list of tasks assigned to a user. This list will only need to include the latest tasks which will imply not sending a list that was previously sent.

There will be no user interaction via a ui to start the workflow so a timer start event will need to be used. There is a incremental task id (lastTaskId) and i can retrieve the last id via sql from the database. I can then preserve this in a variable on the workflow and use a > lastTaskId to get all tasks created post the last dispatch. There is no status value i can update back to the database. The taskid is the only value i can use.

The model I have come up with looks like the below,

  1. Timer starts
  2. Last task id retreived via task Get last task id
  3. Get all tasks with id > last task id via task Get Task Info
  4. Get list of employees
  5. Send email to employees

The issue here is that as the timer event will start a new instance at the interval set the attempt to preserve the state i.e value of the lastTaskId variable, will fail, thus losing track of the last taskid sent. I need to use a timer event to loop back to the Get last task id but i do not see how that will function considering i will be using a timer start event. What would be the best way to model this workflow ?

Hi @Bisoux,

in general, there are two ways to store data: outside of the process (e.g. in an external database), or inside the process instance as variables.

If you really want to store the data (e.g. the lastTaskId) inside the process instance then you need to store it as a process variable and the process instance must keep alive. If the process instance ends then the variable is gone. You could model some sort of loop in the process to prevent the process instance ends.

But there are some disadvantages in using never-ending process instances, for example, it can be harder to monitor the process instance because of the looping and the amount of historic data.

Does this help you?

Best regards,


Hi @philipp.ossler , Yes it does help me. Storing the lastTaskId sent in an external database looks like the only viable option for this use case.