Process variable are not getting saved in database


#1

Hi
I have developed a process model using flowable and made a http request using http task which returns me an object

processVariables = runtimeService.getVariables(processInstance.getId());
using this I can retrieve the object in my java class
processVariables2 = processInstance.getProcessVariables();
but when I did this it gives me null value

Also object doesn’t get saved in database

even I have marked save response as json true

I even tried
runtimeService.setVariables(processInstance.getId(), processVariables);
taskService.setVariables(task.getId(), processVariables);


#2

Hi @sagaraa

How do you fetch processInstance ?


#3

processInstance = runtimeService.startProcessInstanceByKey(myProcessId);


#4

Try this one:

runtimeService.createProcessInstanceQuery().includeProcessVariables().processInstanceId(processInstance.getId())).singleResult();


#5

If your process is completed:

historyService.createHistoricVariableInstanceQuery().processInstanceId(processInstance.getId()).list()

For running process you can also use this one:

runtimeService.getVariables(processInstance.getId())


#6

runtimeService.createProcessInstanceQuery().includeProcessVariables().processInstanceId(processInstance.getId())).singleResult();

it is returning me a processInsatance


#7

Yep. Now call getProcessVariables() on this object.


#8

it gave me the result I wanted but still the variables are not getting stored in the database,
I want to know why it is happening, what mistake I am committing


#9

I am looking the right table
TestDB.dbo.ACT_RU_VARIABLE
right???


#10

Yes. For active processes.
But for completed processes you should check ACT_HI_VARINST


#11

My bad,
So you mean whatever variables I have in ACT_RU_VARIABLE are for the only active/ incomplete processInstances
and ACT_HI_VARINST contains variables for completed processes.
is it???

I am using it for testing purpose it maybe possible my processInstances may stopped due to some error now I want to know, if it is true(that those are incomplete processes) then, how can I access those incomplete variables and continue them where they stopped due to some error because I have to access those process Instances.

Thanks that was really helpful.


#12

Almost. The history table will also contain the runtime variables. Variables will be removed from the runtime table once the process instance has finished.

They should be in the historic variables table. Variables there never get removed.