Based on the “Incidents” ideas, I dug a little into the Java api to see what we can do without to much modification…
Came up with the following:

Where Generate Incident is:
var IncidentEntity = Java.type('org.camunda.bpm.engine.impl.persistence.entity.IncidentEntity');
var IncidentContext = Java.type('org.camunda.bpm.engine.impl.incident.IncidentContext');
var context = new IncidentContext();
context.setActivityId(execution.getCurrentActivityId());
context.setExecutionId(execution.getProcessInstanceId());
context.setProcessDefinitionId(execution.getProcessDefinitionId());
var newIncident = IncidentEntity.createAndInsertIncident("myCustomIncidentType", context, "A custom incident message.");
newIncident.id
I store the newIncident.id as a process variable so in the next task i can search for it and resolve it.
The Resolve Incident task has a Execution Listener with a End type:
execution.getProcessEngineServices().getRuntimeService().createIncidentQuery().incidentId(execution.getVariable('IncidentId')).singleResult().resolve();
This finds the Incident with the IndicidentId process variable as the filter and resolves it. I had to do this, because as far as i can tell there is no Web API to resolve incidents? Incident | docs.camunda.org But maybe i am missing something?
Where .createIncidentQuery() returns a instance of IncidentEntity, and .resolve() is (IncidentEntity (camunda BPM Javadocs 7.6.13-ee))
In Cockpit there is not ability to “resolve” the incidents as a action. Would be nice to have a “generic” resolve function in Cockpit, so you can generate a Incident and resolve it without having to write and deploy custom Java.
Some screenshots of what it looks like in Cockpit:
With Two process instances (1 with a incident, and the other had its incident resolved)
Instance with the Incident:
Instance with the Incident, in the Incidents Tab:
Instance with its Incident Resolved:
References:
- General Info: Incidents | docs.camunda.org
- Example I based my search on: camunda-7-code-examples/CreateCustomIncidentTaskListener.java at master · camunda-consulting/camunda-7-code-examples · GitHub
-
Important!: The Incident Entity I create: IncidentEntity (camunda BPM Javadocs 7.6.13-ee)
- How i find the Entity to resolve it in another task: IncidentQuery (camunda BPM Javadocs 7.6.13-ee)
-
Important!: How to create the Context object which is used in #3 above: IncidentContext (camunda BPM Javadocs 7.6.13-ee)