Hi everyone,
I wanted to ask if there is a way to find boundary events of a certain task using the Java API. I have not yet found that in the docs.
Thanks.
Hi everyone,
I wanted to ask if there is a way to find boundary events of a certain task using the Java API. I have not yet found that in the docs.
Thanks.
hello, my solotion bellow. this code find boundary error event for current activity
var ErrorCode = "GlobalError";
var boun = execution.getProcessInstance().getBpmnModelInstance().getModelElementsByType(BoundaryEvent.class);
System.out.println(ex.getMessage());
for (var item : boun) {
if(item.getAttachedTo().getId().equals(execution.getCurrentActivityId())) {
var definitions = item.getEventDefinitions();
for(var def : definitions) {
if(def.getClass().getSimpleName().equals("ErrorEventDefinitionImpl")){
ErrorCode = ((ErrorEventDefinition)def).getError().getErrorCode();
break;
}
}
}
}
if(ErrorCode.equals("GlobalError")) {
execution.setVariable("ErrorTaskId", execution.getCurrentActivityId());
}
var Errors = execution.getVariable("Errors");
if(Errors==null) {
var Json = new JSONObject();
Json.put(execution.getCurrentActivityId(), new JSONObject(ex.getMessage()));
JsonValue errorJson = SpinValues.jsonValue(Json.toString()).create();
execution.setVariable("Errors", errorJson);
}
else {
var errorJson = new JSONObject(execution.getVariableTyped("Errors").getValue().toString());
errorJson.put(execution.getCurrentActivityId(), new JSONObject(ex.getMessage()));
JsonValue error = SpinValues.jsonValue(errorJson.toString()).create();
execution.setVariable("Errors", error);
}
throw new BpmnError(ErrorCode, ex.getMessage());
}
look this