Service Task Escalation

Hi,
Is it possible to report BPMN escalation on running service tasks through API or REST similar to what that is for user tasks in TaskService and in REST API?

thanks

1 Like

@mjalil, TaskService provides Java api to create escalations for service tasks.

@Component
public class ProductShippingDelegate implements JavaDelegate {

      @Autowired
      private ShippingService shippingService;
	  
      @Override
	  public void execute(DelegateExecution execution) throws Exception {
			boolean isProductShippable = shippingService.checkForProductDelivery(execution.getVariable("productId"));
			
            if (!isProductShippable) {
			    
               TaskService taskService = execution.getProcessEngineServices().getTaskService();
			    
               Map<String, Object> variables = Variables.createVariables()
                  .putValue("productId", execution.getVariable("productId"))
				  .putValue("isProductShippable", isProductShippable);
			    
               taskService.handleEscalation(execution.getId(), "ESC_SHIP_002", variables);
			}
	  }
}

Note: handleEscalation() function is available from camunda version 7.12

For service tasks, rest api won’t work since it’s been executed by engine itself.

Check the difference between Service Task and User Task for how it works.

you pass execuition.getId() as the first argument to handleEscalation, but the documentation is passing taskId. Is it correct?

my service tasks are external all and I call REST to complete them, so IMHO it’s meaningful to me to Escalate .
If execution Id IS the argument to escalate a task so I have it in my external service task

It’s better to attach the escalation event as boundary event for that external service task.

yes, I do attach as boundry event, but how to call REST? with execution Id? like this:
POST /task/{executionId}/bpmnEscalation

@aravindhrs
I tried to use taskService.handleEscalation(execution.getId(), "ESCALATION_CODE") but I get error:

Cannot find task with id 720cfb29-24d1-11eb-a4c5-0242ac120003: task is null

How to get the Task ID in the Java Delegate?

Regards,
Yogesh

You can query using taskservice

@aravindhrs
I tried with TaskService as well using below code but the task is null for the execution id. How can that be?
I don’t know if it matters but my Service task that is using the Java Delegate is marked as async before=true. Is that the reason, I cannot get task inside Java delegate?

Task task = execution.getProcessEngineServices().getTaskService().createTaskQuery().executionId(execution.getId()).singleResult();

Since I would also like to use this, here is a new topic: Service Task Escalation // ParseException