AnsweredAssumed Answered

Get all user tasks for a process definition/instance

Question asked by viralparekh on Jan 8, 2016
Latest reply on Jan 20, 2016 by jbarrez
I have a simple requirement - I need to get all user tasks for a given process. Using taskservice or historyservice only gives me active or completed tasks. How do I get all the tasks in a process? I have found the below code from some earlier forum threads. Is this acceptable? I believe there should be a better public API than this.


ProcessDefinitionEntity processDefinition =
            (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService).getDeployedProcessDefinition(processInstance.getProcessDefinitionId());

        if (processDefinition != null) {
            for (ActivityImpl activity : processDefinition.getActivities()) {
              String type = (String) activity.getProperty("type");
              String name = (String) activity.getProperty("name");
              String taskId = activity.getId();

              System.out.println("type: "+type+" name: "+name + " id: " + taskId);

            }
        }

Outcomes