Get all tasks from in a workflow, including the tasks in call activity

I am having a workflow which has call activity, i need to now get all tasks in the workflow including the tasks in the call activity.

How can this be done using JAVA API ?

The following is my workflow

I can get the tasks in workflow including the tasks inside subprocess using the api getFlowElements() of subprocess.
But now i need to get the tasks in call activity too from the parent workflow itself, can this be done through a JAVA API ?

1 Like

Hi @Ranjith_Kannan,

just to clarify, do you want to get all user tasks (i.e. to work / complete these tasks via task service) or all flow elements of type task?
Please describe your use case a bit more.

Best regards,
Philipp

Hi Philipp

I would like to do both.
I want to list down all tasks of particular type from start event till end event, including the tasks in subprocess and call activity along with the parent’s tasks from the workflow definition.
Using task service is it possible to get the next task to be executed after execution of current task ?

Thanks
Ranjith

I can’t give you the precise Java code to do this as I don’t have the necessary experience. However, if I had to do this I would take the value of the “calledElement” attribute (in the source XML) and use it to reference the “child” process.

If you have to do this in a “brute force” manner, you could use the REST API to get the parent process XML and using XPath, find the “callActivity” attributes which would contain the “calledElement” attribute, which would in turn allow you to use the REST API to get the child process XML, etc.

Once you have the XML, you would have to use a parser (XPath, etc.) to extract the tasks from the output of the REST API. The REST API request would be something like:

http://localhost:8080/engine-rest/engine/default/process-definition/key/myParentProcess/xml

From that you would get the called element (e.g. myChildProcess) which would then be fed into:

http://localhost:8080/engine-rest/engine/default/process-definition/key/myChildProcess/xml

I know you’re looking to do this in the JAVA API, so this is merely a conceptual “alternative” which doesn’t really solve your problem.

If you look in the Java doc, there is a getTasks() method, but there is no explanation of it’s usage, though it seems promising.

1 Like

Hi @Ranjith_Kannan,

in addition to @mppfor_manu, you can also use the Model Api to get all activities of a process definition. If you want to get the activities of a subprocess then you have to be aware that the specific version of the definition is resolved at runtime.

Best regards,
Philipp

1 Like

Thanks a lot @mppfor_manu and @Philipp_Ossler for your answers and time, i shall try this and share the approach and solution in this thread.

Best Regards
Ranjith

Any solution reached? I’m facing the same problem… given a processInstanceId, hou should I query for all active user tasks or activities belonging to this processInstanceId or any called activity?

Should this be done by querying recursively all subtree of processInstances by field processInstanceQuery.superProcessInstanceId(String superProcessInstanceId)? Isn’t there a single query to get them all? This is not available for tasks, so I supose I have to get recursively all subProcessInstances and then all open tasks for each one.

1 Like