Navigating a processInstance to execute the next activity

I am currently evaluating Camunda for use within our organisation and I am experimenting and evaluating different ways of using the application.

I would like to be able to interrogate a given process instance - through the RestAPI - such that I can find the current task (or activity) and then execute that task. Is this possible and/or a sensible way to use Camunda?

Kind regards,

Rob

Sure, everything that is happening or has happened is stored in history tables.
That data is accessible though the History REST API.

Thanks very much for the prompt response. Seems a little convoluted to achieve what I need to achieve? I can interrogate a process instance and through its activity instance receive the current “child task” using:

http://localhost:8080/engine-rest/process-instance/{id}/activity-instances

But I can’t seem to retrieve any id that will then enable me to call:

http://localhost:8080/engine-rest/task

to execute the task? Am I completely misunderstanding something?

Kind regards,

Rob

Are you trying to get and complete a user task? Or an external task?

A user task.
Thanks
Rob

Hi Rob,

Indeed if you’re using theGet Tasks call it will return any user tasks that match whatever criteria you’ve added. In the case where you specify no criteria it will return all currently active user task. The only reason it would be return nothing is if there are not active user tasks or the criteria doesn’t match any.

You don’t need to query for a task matching a specific ID, instead if you use the above rest call you’ll get an ID in return and then you can use it to complete the task via Rest.

Hope that helps.

Hi Niall

Tx very much for your response. So if I call Get Tasks with a specific process instance id I will get the active task(s) for that specific process instance?

Kind regards,

Rob

Correct - although it’s generally better practice to use a business key when searching for tasks.

You can start a process with a key (any string that makes sense for you use case) and then use that same key to query for tasks. One of reasons why this is a better idea is because if you use a sub process within your process, it will have a difference process instance id - but you can pass a business key to a sub process.

Niall

That’s great - thanks for your advice.

Kind regards

Rob