Custom Incident Handler not able to get execution variable

Hi,
I have a service task in the process model. On the service task a Delegate class is called, which makes a rest call to down stream system. When we get the response, based on the error code in the response, we need to create custom incident, which can be handled by custom incident handler, which is there in application. Following two approaches we have tried:

  1. throw new Exception(“”) when there is some error code in response
  2. execution.createIncident()
    Before we do any of these, we need to set some execution variables like error code, error message etc in delegate class so that they can be accessed in incident handler. But, what we found is incident handler is not able to access any execution variables set inside this delegate class. It is able to access other execution variables which are set in the previous tasks in the process. Can you please suggest, what can be the issue here ?

Hi @jdhwani,

I would just mark the service task as “Asynchronous before” and

throw new Exception(code from the response);

will create an incident automatically.

Your handler will then have access to the execution.

Hope this helps, Ingo