cancel
Showing results for 
Search instead for 
Did you mean: 

Task Operation API calls

hmesha
Champ in-the-making
Champ in-the-making
Hi all,

How one would initiate perform task action using the API through the task service interface? The use case here is a user would have initiated an approval or rejection action and I'd like to notify the execution to apply the action to the task and therefore the process instance will continue on.

Thanks,

Hany Mesha
1 REPLY 1

frederikherema1
Star Contributor
Star Contributor
You can create a simple approve/reject flow using a exclusive gateway:

..

<exclusiveGateway id="exclusiveGw" name="Exclusive Gateway" />
   
<sequenceFlow id="flow2" sourceRef="exclusiveGw" targetRef="approvedTarget">
  <conditionExpression xsi:type="tFormalExpression">${approved}</conditionExpression>
</sequenceFlow>
   
<sequenceFlow id="flow3" sourceRef="exclusiveGw" targetRef="rejectedTarget">
  <conditionExpression xsi:type="tFormalExpression">${!approved}</conditionExpression>
</sequenceFlow>

..

To finish the task using TaskService, you can do this to approve/reject:

Map<String, Object> variables = new HashMap<String, Object>();
variables.put("approved", Boolean.FALSE);

// Finish the task, passing the approved variable
taskService.completeTask(task.getId(), variables);

Does this answer your question?