cancel
Showing results for 
Search instead for 
Did you mean: 

Get the activity from the task

frauke
Champ in-the-making
Champ in-the-making
Hello everybody,

how can I retrieve the activity from a task?
I tried this way, but the activity of this execution is null, although the activityId has the expected value.

        Execution ex = processEngine.getRuntimeService()
            .createExecutionQuery()
            .executionId(task.getExecutionId())
            .singleResult();
        PvmActivity activity = ((ExecutionEntity) ex).getActivity(); // is null
        String actId = ((ExecutionEntity) ex).getActivityId(); // is not null

The same code works with the process instance, but what I need is the currently active activity after branching with an exclusive gateway.
Is there an other way of getting the activity?

Best regards
Frauke
1 REPLY 1

frauke
Champ in-the-making
Champ in-the-making
Hi,

seems like I found out by myself:

        Execution ex = m_processEngine.getRuntimeService()
            .createExecutionQuery()
            .executionId(task.getExecutionId())
            .singleResult();
        String actId = ((ExecutionEntity) ex).getActivityId();
        ProcessDefinitionImpl p = ((ExecutionEntity) m_processInstance)
            .getActivity()
            .getProcessDefinition();
        PvmActivity activity = p.findActivity(actId);
Ok, it may not look extremly elegant, but it works.
Still the other way would be easier…

Regards
Frauke
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.