How execute a (human) task with contract defined input values using the java API ?

Hello.

I’m looking at the java API documentation, and I have not found any way to execute a task setting its contract inputs values at the same time ?

The goal is to design processes with human tasks, using the contract variables to define what should be user’s input, but execute them from external systems (exposing web services in our case).

What is the best design for that ?

Thanks for your help.

Regards.

Hi,

Take a look at ProcessRuntimeAPI.executeUserTask()
To get an instance of a ProcessAPI, which is a sub interface of ProcessRuntimeAPI, use TenantAPIAccessor.getProcessAPI()

Hope this helps

Regards

Hello.
In deed, this seems to be the solution. I’ve seen the API operation before, but I didn’t understand that it involves the task’s contract inputs.
We’re still at a pre-design step, and we’ll do the first prototyping code in few weeks.
I keep your advice and I’ll come back to tell you about our results.
Thanks a lot.
Regards.

Hello
Could you share a sample code.
I am having issues passing task contract inputs to the above method.
thanks

Here is a short example of how to execute a task with some contract inputs (note the task need to be assigned to the user, this is why we use assignAndExecuteUserTask method instead of executeUserTask):

HashMap<String, Serializable> book = new HashMap<>();
book.put("title", "A book title");
book.put("summary", "A book summary");
Map<String, Serializable> contractValues = new HashMap<>();
contractValues.put("aBookInput", book);
apiClient.getProcessAPI().assignAndExecuteUserTask(apiClient.getSession().getUserId(), 200002L, contractValues);
// 200002L is the id of the task in my example

If you need more help on this topic please create a new question. Thanks.

Thank you antoine. Its working for me.
I am building a custom page to show all pending tasks for a users and complete them in one attempt.
This will help me a lot.