Search code examples
flowable

runtimeservice.getVariables does not work because it can't find process instance id


I'm new to flowable and I'm trying to start a process instance with variables. params here is the Map of <String,Object> that I'm using to start the process. It all goes well, but if I try to get my variables back it tells me

"execution 22f42f67-5f88-11e9-9df0-d46d6dbfea92 doesn't exist"

But if I search for it in my process instances list, is there. This is what I do:

pi = runtimeService.startProcessInstanceById(processDefinitionId, params);
runtimeService.getVariables(pi.getId());

I'm stuck with this problem and I do not understand why it keeps doing this. What am I missing?


Solution

  • Flowable has the concept of RuntimeService and HistoryService. The first one contains only the runtime data (what is currently active) and the second one has all the data. The runtime data is a subset of the history data.

    The reason why you can’t find the variables via the RuntimeService is due to the fact that the process is completed.

    If you use the HistoryService then it would work as expected.