Uploaded image for project: 'camunda BPM'
  1. camunda BPM
  2. CAM-1689

I can create / resolve an incident through public API

    • Icon: Feature Request Feature Request
    • Resolution: Fixed
    • Icon: L3 - Default L3 - Default
    • 7.8.0, 7.8.0-alpha2
    • None
    • engine
    • None

      It should be possible to create and resolve incidents through public API.

      AT:

      • RuntimeService API
        runtimeService.createIncident(String incidentType, String executionId, String activityId, String configuration)
        runtimeService.resolveIncident(String incidentId)
        
      • DelegateExecution
        execution.createIncident(String incidentType, String configuration)
        execution.resolveIncident(String incidentId)
        
      • REST api enhancements
        • I can create resolve / incidents through REST api as well.

        This is the controller panel for Smart Panels app

            [CAM-1689] I can create / resolve an incident through public API

            +1

            Stephen Russett added a comment - +1

            function Incidents(){};
            Incidents.prototype.createIncident = function(incidentType, incidentMessage) {
            
              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(incidentType, context, incidentMessage);
            
              return newIncident;
            };
             
            Incidents.prototype.resolveIncident = function(incidentId){
            
                execution.getProcessEngineServices()
                         .getRuntimeService()
                         .createIncidentQuery()
                         .incidentId(incidentId)
                         .singleResult()
                         .resolve();
            }
            

            Stephen Russett added a comment - function Incidents(){}; Incidents.prototype.createIncident = function(incidentType, incidentMessage) { 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(incidentType, context, incidentMessage); return newIncident; }; Incidents.prototype.resolveIncident = function(incidentId){ execution.getProcessEngineServices() .getRuntimeService() .createIncidentQuery() .incidentId(incidentId) .singleResult() .resolve(); }

            Matthijs added a comment -

            Matthijs added a comment - Proofread commit (with a typo in the commit message): https://github.com/camunda/camunda-docs-manual/commit/07cddec6f8da46814d51adb1497c48be4825b1e4

              Unassigned Unassigned
              meyer Daniel Meyer
              Votes:
              2 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: