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

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 ?

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

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 ?

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.

2 Likes

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!

2 Likes

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 ?

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.

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.

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 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.

2 Likes

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 ?

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

2 Likes

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.

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.

1 Like

My request was to store the value internally not externally