AnsweredAssumed Answered

Get name of currently processed activity

Question asked by serid on Sep 5, 2016
Latest reply on Sep 5, 2016 by serid
Hi All,

I am trying to achieve what seems to be an easy task - get currently activity name being processed.
I have an UI which shows currently running process and a progress bar which shows the progress of a ServiceTask.
If activity is something different - eg ScriptTask or a UserTask - it does not show the progress bar but only spinning wheel.
I also want to show the current task name being processed.

Is there a simple way to achieve it ?

I thought I would set a variable "current-activity" with the name of the activity like so:


case ACTIVITY_STARTED:
   if (ActivitiActivityEvent.class.isAssignableFrom(event.getClass())) {
      ActivitiActivityEvent activitiEvent = (ActivitiActivityEvent) event;
      runtimeService.setVariable(event.getExecutionId(), "current-activity", activitiEvent.getActivityName());
   }
break;


That code is in a service layer which listens to ActivitiEvent.
Please keep in mind that UI might be opened by a user in a middle of processing the activiti process.

I have a piece of code on the UI that does:


(String) activitiService.getRuntimeService().getVariable(execution.getId(), "current-activity"));


but it seems to be picking up only the previous variable content. I suspect it has to do with the transactions management.


Thanks,
Adrian

Outcomes