Process step count


Is there a possibility to count and display process steps f.e. in the embedded forms? Currently I can only display service task names in the forms, depending on which step of the process is currently being taken, but sometimes I have a loop where we have to do a few review and approve steps and there is currently no way to get the specific number of those steps, only the task names, which are constant.

Hope you understand what I mean.
Thanks and kind regards,


Depending on what exactly you are looking for, the historic activity instance query accessible via HistoryService#createHistoricActivityInstanceQuery may help you. Alternatively, you can set a custom process variable that keeps track of executed activities and that you update for every activity via an execution listener.



Thanks for the quick reply. I need to be able to show my user the step he is currently taking. But I also want to record how many times the user has taken the following steps.

Imagine a situation of hiring an employee. Say the request gets rejected multiple times due to different reasons. This means that some process steps will be taken multiple times. I need to be able to record how many times these steps have been taken and show them inside a form.

I have been thinking of displaying steps inside the forms, but this will not be able to show how many times that exact step has been taken. I was then thinking about using the modeler for this, maybe it can somehow save a value, but then again it will also start a java class every time when executing a listener and overwriting previous variable data.

Any help would be greatly appreciated.

Kind regards,

On the other hand I could do that all via angular object. I do not need to keep that data anywhere besides the current ongoing process. So i can treat this as a simple variable manipulation.


I’m still not sure what exactly you mean when you write

But I also want to record how many times the user has taken the following steps.

If this about user task instances, then you could make a historic task instance query like so: historyService.createHistoricTaskQuery().taskAssignee("theCurrentUser").processInstanecId("idOfThisProcessInstance").list(); and then manually group the results by task definition key (which is equal to the activity id) and count the occurrences. This query is also available via REST API.

If you have a lot of tasks, fetching the tasks and manually grouping them may be ineffecient. Then you will have to implement a custom SQL query on the table ACT_HI_TASKINST.

Of course you can also maintain a process variable that collects the desired information over time like you propose.


I have managed to implement this feature in the following way (if somebody will stumble upon the same question in the future):

I have two listener classes (B, C) extending one abstract class (A) which is implementing Camunda TaskListener interface.

A class is doing:

  1. Counting the total process step count via
    HistoryService historyService = ProcessEngines.getDefaultProcessEngine().getHistoryService();
    int historicalStepCount = historyService.createHistoricTaskInstanceQuery().taskAssignee(taskAssignee)

  2. Storing this value for future use in the frontend:
    delegateTask.setVariable(“totalStepCount”, (historicalStepCount + 1));

  3. Counting the amount of times a current step is taken and then storing that value for future frontend use via referring the methods inside the classes B & C.

In the modeler I have referenced the class B & C as task listeners on the necessary steps with even type: start.

Hope this helps somebody, who may have the same task in the future.