End Process-Instance trough Conditional-Start-Event

Hey :slight_smile:

I have a simple process:

56

The goal is, that the instance which will be active in “Test” should be killed trough the Service-Task “Abbruch”. To start the Service-Task I use the following post request:

{
  "variables" : {
    "abbruch" : {"value" : "true", "type": "boolean"}
  },
  "businessKey" : "1"
}

The Service-Task itself contains the following Java-Code:

@Override
	public void execute(DelegateExecution execution) throws Exception {
		// TODO Auto-generated method stub
		
		String processID = execution.getProcessDefinitionId();
		List<String> activeIDs = execution.getProcessEngineServices().getRuntimeService().getActiveActivityIds(processID);
		
		for (int i = 0; i <= activeIDs.size(); i++) {
			execution.getProcessEngineServices().getRuntimeService().suspendProcessInstanceById(activeIDs.get(i));
		}
		
		 
	}

The idea behind the Code is, it gets all activeIDs and then kills them one by one trough the for-loop.

If I now start the process and sent the POST-Request I get the following error-message:

{
“type”: “NullValueException”,
“message”: “execution deletion:1:20b97687-2fdb-11ea-9c8a-0242ac110002 doesn’t exist: execution is null”
}

Is that somehow related to the for-loop? Do I kill the instance and therefore the POST-Request can’t find the execution? :see_no_evil:

Thanks for your help!

Best wishes,
Matthias
process.bpmn (4.0 KB)