Unable to get currentFlowElement for an execution


For an ad-hoc subprocess execution, I am trying to get the current flow element. But getting flowable exception saying: Cannot get process model: no current command context is active.

ExecutionEntity execution  = (ExecutionEntity) runtimeService.createExecutionQuery().executionId(executionId).singleResult());
if(execution.getCurrentFlowElement() instanceof AdhocSubProcess){

here execution.getCurrentFlowElement() causing above flowable exception.

Hey @HarishArawala,

What you are trying to do is not supported. You are casting to the implementation details of the Execution. You can’t achieve that when using the query.

You can get the flow element of the execution by using the API in the following way:

BpmnModel model = repositoryService.getBpmnModel(execution.getProcessDefinitionId);
Process process = model.getMainProcess();

FlowElement executionFlowElement = process.getFlowElement(getCurrentActivityId(), true);
// do what you need with this


1 Like

Hi @filiphr

We are facing similar issue wherein getCurrentFlow elements is always null. Below below is code snippet the way we fetch it at runtime which brings in collection of executions which has all the details but how do I find the current execution. This use to work fine in activiti 5 but fails in flowable 6.5

The above you suggest will work only if we have currentActivityId which seems to be null. Any ideas?

ExecutionEntity execution = CommandContextUtil.getExecutionEntityManager(Context.getCommandContext()).findById(executionId)