# Is it possible to store variable value to be used in the next run?

**URL:** <https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879>\
**Category:** Features\
**Created:** [June 30, 2024, 8:52pm UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879 "2024-06-30T20:52:57Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![duchesselily](https://forum.electroneek.com/letter_avatar_proxy/v4/letter/d/bbce88/32.png) [@duchesselily](https://forum.electroneek.com/u/duchesselily)\
**Post date:** [June 30, 2024, 8:52pm UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/1 "2024-06-30T20:52:57Z")

</div>

I would like to read a value and compare it with the previous run value, is it possible to store this value internally at the end of the workflow ?  
Even though I uncheck the “clear variables before execution”, my variables are still empty.  
How can I store the previous value ?

---

<div class="post-metadata">

**Author:** ![a.polianskii](https://forum.electroneek.com/user_avatar/forum.electroneek.com/a.polianskii/32/1683_2.png) [@a.polianskii](https://forum.electroneek.com/u/a.polianskii)\
**Post date:** [July 1, 2024, 7:24pm UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/2 "2024-07-01T19:24:39Z")

</div>

hey @duchesselily,

In the Orchestrator, there is Output data feature where you can select the variables so it could be reused by other workflows once the first one is finished. Please refer to the [article](https://docs.electroneek.com/page/how-tos-studio-pro#how-to-work-with-the-output-tab) to learn more about it.

Also, you can save a value of a variable to a file using activities from the ‘OS Automation’ group of activities (for example, a .json file).

---

<div class="post-metadata">

**Author:** ![duchesselily](https://forum.electroneek.com/letter_avatar_proxy/v4/letter/d/bbce88/32.png) [@duchesselily](https://forum.electroneek.com/u/duchesselily)\
**Post date:** [July 2, 2024, 7:23am UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/3 "2024-07-02T07:23:45Z")

</div>

I do not pinpoint the part on how I can get the output data from my previous run to the next one.  
I only see the possibility to pass data from subprogram a.neek to subprogram b.neek.

That is not what I am trying to do here.

I want to know if it is possible to pass data from program a.neek that ran at time t-1 to program a.neek that runs at time t.

Is that feasible in ElectroNeek ?

---

<div class="post-metadata">

**Author:** ![Shahan\_Saeed](https://forum.electroneek.com/user_avatar/forum.electroneek.com/shahan_saeed/32/1481_2.png) [@Shahan\_Saeed](https://forum.electroneek.com/u/Shahan_Saeed)\
**Post date:** [July 2, 2024, 12:50pm UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/4 "2024-07-02T12:50:18Z")

</div>

Hi @duchesselily,

To store a value and compare it with the previous run in Electroneek, you can use variables effectively within your workflow. If you’ve unchecked “clear variables before execution” and still find your variables empty, then you can use two method:  
1): Use “Global Variables”, if you want to store a value across different runs of your workflow. Ensure that you define and initialize these variables appropriately at the start of your workflow.  
2): “Set and Update Variables” , after reading a value, set it to the global variable. For comparing with the previous run value, you can read the previously stored global variable and compare it with the current value.

---

<div class="post-metadata">

**Author:** ![duchesselily](https://forum.electroneek.com/letter_avatar_proxy/v4/letter/d/bbce88/32.png) [@duchesselily](https://forum.electroneek.com/u/duchesselily)\
**Post date:** [July 2, 2024, 4:05pm UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/5 "2024-07-02T16:05:02Z")

</div>

Hey, thanks for the input.

I had done all that but I have noticed that creating the variable from Project Settings, even though you use it in assign value activities and flag it as global and uncheck the “clear variables before execution” will still make it reset the value to the one defined in Project Settings.  
I removed the variable from there and now my value is stored successfully.

Great!

---

<div class="post-metadata">

**Author:** ![duchesselily](https://forum.electroneek.com/letter_avatar_proxy/v4/letter/d/bbce88/32.png) [@duchesselily](https://forum.electroneek.com/u/duchesselily)\
**Post date:** [July 3, 2024, 3:41pm UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/6 "2024-07-03T15:41:53Z")

</div>

Unfortunately, this only works from my local machine. Once I publish the workflow on the Orchestrator and run it from there, it fails with error variable is not defined.  
How can I go around this ?

I basically use 2 global variables: old\_price and new\_price. In the beginning of the script I scrape the new price and assign the value to global variable new\_price. I then compare new\_price with old\_price, if it is different, I assign new\_price to old\_price.

The issue is that my IF fails as old\_price is not yet defined at that step in workflow, even though it is defined as a global variable.  
I tried to do a check on wether the variable is empty, but this check also fails, I think the issue is that even though the variable is global, it is not considered declared until we reach the assign value activity.

How can I solve this ?

---

<div class="post-metadata">

**Author:** ![a.polianskii](https://forum.electroneek.com/user_avatar/forum.electroneek.com/a.polianskii/32/1683_2.png) [@a.polianskii](https://forum.electroneek.com/u/a.polianskii)\
**Post date:** [July 3, 2024, 6:00pm UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/7 "2024-07-03T18:00:51Z")

</div>

hey @duchesselily,

This is expected if you refer to the variable that is not defined yet. When you publish the bot to Orchestrator and run it from there, the Bot Runner application is executing the bot (not the Studio Pro). Therefore, as this app has never created the old\_price variable, you received the mentioned error. Firstly, create the variable you are using in the algorithm and then reuse it to define other variables. As already suggested, you can add in the workflow a step to store the data between the runs in a file and read it each time you start the bot (to define the old\_price variable).

In this case, even a machine would be restarted (and the Bot Runner memory would be erased), your workflow will continue to work.

---

<div class="post-metadata">

**Author:** ![duchesselily](https://forum.electroneek.com/letter_avatar_proxy/v4/letter/d/bbce88/32.png) [@duchesselily](https://forum.electroneek.com/u/duchesselily)\
**Post date:** [July 4, 2024, 2:13pm UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/8 "2024-07-04T14:13:24Z")

</div>

Ok, got it!

What exactly do you mean by “firstly, create the variable you are using in the algorithm and then reuse it to define other variables” ?  
Is there any other way to create it than using the “assign value” activity ? What value should I assign it, considering the value is used as a comparison with current scraped price, therefore I cannot just assign it any value.

Also, it is not used to define any other variables.

I understand it is possible to store that value outside of the tool but if there is a way to do it within the tool I would like to understand how and use that feature to the fullest. If the feature did not exist, of course I would simply store it in a local file.

---

<div class="post-metadata">

**Author:** ![a.polianskii](https://forum.electroneek.com/user_avatar/forum.electroneek.com/a.polianskii/32/1683_2.png) [@a.polianskii](https://forum.electroneek.com/u/a.polianskii)\
**Post date:** [July 4, 2024, 6:46pm UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/9 "2024-07-04T18:46:42Z")

</div>

hey @duchesselily,

> then reuse it to define other variables

I meant this as I was not sure how you are using the **old\_price** variable with the **new\_price** and thought that you are using the old price in order to create a new one. The same logic can be applied to the comparison - if you want to use a variable in comparison, it should be **firstly created** (with the ‘Assign value to variable’ activity).

We do have[the feature](https://docs.electroneek.com/page/how-tos-studio-pro#how-to-work-with-the-output-tab) to store the variable values between runs and different algorithms, for this that I mentioned in my first reply. But the question here we are discussing is probably about the logic of a cause and a effect - you need to create a variable first in order to compare it. So either you can create it with value 0 and then compare it in the algorithm, or you can use a file to store the past price. The choice depends on the needs of the business requirements.

---

<div class="post-metadata">

**Author:** ![duchesselily](https://forum.electroneek.com/letter_avatar_proxy/v4/letter/d/bbce88/32.png) [@duchesselily](https://forum.electroneek.com/u/duchesselily)\
**Post date:** [July 6, 2024, 10:40am UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/10 "2024-07-06T10:40:26Z")

</div>

Okay but if I first assign old\_price to 0, won’t it defy the purpose of later saving new\_price to old\_price for comparison in the next run ? Since I reset old\_price to 0, won’t I always be comparing new\_price with 0 ?

---

<div class="post-metadata">

**Author:** ![Martinp](https://forum.electroneek.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@Martinp](https://forum.electroneek.com/u/Martinp)\
**Post date:** [July 6, 2024, 8:41pm UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/11 "2024-07-06T20:41:02Z")

</div>

As a suggestion, why not store the variable/valie in a file that gets read at the start of your automation (and stored at the end)?

---

<div class="post-metadata">

**Author:** ![a.polianskii](https://forum.electroneek.com/user_avatar/forum.electroneek.com/a.polianskii/32/1683_2.png) [@a.polianskii](https://forum.electroneek.com/u/a.polianskii)\
**Post date:** [July 8, 2024, 5:47pm UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/12 "2024-07-08T17:47:24Z")

</div>

hey @duchesselily,

There is no need to assign 0 to old\_price for all the cases. I listed a few options and that was just an example, the choice depends on the business requirements. In any case, as was mentioned previously, you can use a file to store the values and it will be settled.

---

<div class="post-metadata">

**Author:** ![duchesselily](https://forum.electroneek.com/letter_avatar_proxy/v4/letter/d/bbce88/32.png) [@duchesselily](https://forum.electroneek.com/u/duchesselily)\
**Post date:** [July 12, 2024, 8:21am UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/13 "2024-07-12T08:21:27Z")

</div>

Ok, thanks.

I only have the one case: read a value and compare it to the value that was read in the previous run. Therefore, as I explained, I cannot assign the value to 0 or just any other value, because that would void my comparison.

I will just assume that it is not possible to store a dynamic value in a variable internally to be used in the next run, and that limitation comes from the fact we cannot simply declare a value without assigning it any value.

The only solution is to store it externally.

Thanks for your help, though.

---

<div class="post-metadata">

**Author:** ![duchesselily](https://forum.electroneek.com/letter_avatar_proxy/v4/letter/d/bbce88/32.png) [@duchesselily](https://forum.electroneek.com/u/duchesselily)\
**Post date:** [July 12, 2024, 8:23am UTC](https://forum.electroneek.com/t/is-it-possible-to-store-variable-value-to-be-used-in-the-next-run/3879/14 "2024-07-12T08:23:10Z")

</div>

My request was to store the value internally not externally
