04-17-2017 05:01 AM
I'm trying to handle a PROCESS_COMPLETED event by creating an ActivityEventListener bean:
@Override
public void onEvent(ActivitiEvent event) {
final ProcessInstance processInstance = event.getEngineServices().getRuntimeService()
.createProcessInstanceQuery().processInstanceId(event.getProcessInstanceId())
.includeProcessVariables().singleResult();
}
first of all event.getProcessInstanceId() returns an id that does not exist in the database, second ProcessInsantceQuery seems to only return process instances that are not completed(hence processInstance == null). My goal is to get the variables of every process instance that is completed. how can I achieve this?
04-17-2017 08:54 AM
I was able to get the variable I wanted like this:
String var = (String) ((ExecutionEntity) ((ActivitiEntityEventImpl) event).getEntity()).getVariable("var");
And I noticed that the id returned by event.getProcessInstanceId() will exist in the database after event handling is finished. Perhaps only the history of the process instance is saved in that table. My problem is fixed; but still it would be nice to be able to query finished process instances and unfinished alike.
Explore our Alfresco products with the links below. Use labels to filter content by product module.