# Process variable are not getting saved in database

**URL:** <https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724>\
**Category:** Uncategorized\
**Created:** [October 12, 2018, 12:34pm UTC](https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724 "2018-10-12T12:34:18Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sagaraa](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/sagaraa/32/973_2.png) [@sagaraa](https://forum.flowable.org/u/sagaraa)\
**Post date:** [October 12, 2018, 12:34pm UTC](https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724/1 "2018-10-12T12:34:18Z")

</div>

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);

![flowable2](https://cdck-file-uploads-canada1.s3.dualstack.ca-central-1.amazonaws.com/flex035/uploads/flowable/original/1X/03930bff608764120146f76c5257d8efd532d933.png)

---

<div class="post-metadata">

**Author:** ![rgorzkowski](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/rgorzkowski/32/1365_2.png) [@rgorzkowski](https://forum.flowable.org/u/rgorzkowski)\
**Post date:** [October 12, 2018, 1:25pm UTC](https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724/2 "2018-10-12T13:25:37Z")

</div>

Hi @sagaraa

How do you fetch _processInstance_ ?

---

<div class="post-metadata">

**Author:** ![sagaraa](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/sagaraa/32/973_2.png) [@sagaraa](https://forum.flowable.org/u/sagaraa)\
**Post date:** [October 12, 2018, 1:50pm UTC](https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724/3 "2018-10-12T13:50:20Z")

</div>

processInstance = runtimeService.startProcessInstanceByKey(myProcessId);

---

<div class="post-metadata">

**Author:** ![rgorzkowski](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/rgorzkowski/32/1365_2.png) [@rgorzkowski](https://forum.flowable.org/u/rgorzkowski)\
**Post date:** [October 12, 2018, 2:03pm UTC](https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724/4 "2018-10-12T14:03:57Z")

</div>

Try this one:

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

---

<div class="post-metadata">

**Author:** ![rgorzkowski](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/rgorzkowski/32/1365_2.png) [@rgorzkowski](https://forum.flowable.org/u/rgorzkowski)\
**Post date:** [October 12, 2018, 2:07pm UTC](https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724/5 "2018-10-12T14:07:30Z")

</div>

If your process is completed:

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

For running process you can also use this one:

> runtimeService.getVariables(processInstance.getId())

---

<div class="post-metadata">

**Author:** ![sagaraa](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/sagaraa/32/973_2.png) [@sagaraa](https://forum.flowable.org/u/sagaraa)\
**Post date:** [October 12, 2018, 2:09pm UTC](https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724/6 "2018-10-12T14:09:25Z")

</div>

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

it is returning me a processInsatance

---

<div class="post-metadata">

**Author:** ![rgorzkowski](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/rgorzkowski/32/1365_2.png) [@rgorzkowski](https://forum.flowable.org/u/rgorzkowski)\
**Post date:** [October 12, 2018, 2:10pm UTC](https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724/7 "2018-10-12T14:10:13Z")

</div>

> [@sagaraa](#):
>
> it is returning me a processInsatance

Yep. Now call getProcessVariables() on this object.

---

<div class="post-metadata">

**Author:** ![sagaraa](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/sagaraa/32/973_2.png) [@sagaraa](https://forum.flowable.org/u/sagaraa)\
**Post date:** [October 12, 2018, 2:19pm UTC](https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724/8 "2018-10-12T14:19:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![sagaraa](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/sagaraa/32/973_2.png) [@sagaraa](https://forum.flowable.org/u/sagaraa)\
**Post date:** [October 12, 2018, 2:36pm UTC](https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724/9 "2018-10-12T14:36:25Z")

</div>

I am looking the right table  
TestDB.dbo.ACT\_RU\_VARIABLE  
right???

---

<div class="post-metadata">

**Author:** ![rgorzkowski](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/rgorzkowski/32/1365_2.png) [@rgorzkowski](https://forum.flowable.org/u/rgorzkowski)\
**Post date:** [October 12, 2018, 2:41pm UTC](https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724/10 "2018-10-12T14:41:34Z")

</div>

Yes. For active processes.  
But for completed processes you should check ACT\_HI\_VARINST

---

<div class="post-metadata">

**Author:** ![sagaraa](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/sagaraa/32/973_2.png) [@sagaraa](https://forum.flowable.org/u/sagaraa)\
**Post date:** [October 12, 2018, 3:49pm UTC](https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724/11 "2018-10-12T15:49:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![joram](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.flowable.org/joram/32/26_2.png) [@joram](https://forum.flowable.org/u/joram)\
**Post date:** [October 18, 2018, 8:30am UTC](https://forum.flowable.org/t/process-variable-are-not-getting-saved-in-database/2724/12 "2018-10-18T08:30:31Z")

</div>

> [@sagaraa](#):
>
> 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.

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

> [@sagaraa](#):
>
> 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.

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