Variable scope in Reframework

Hello Team,
Need your help.I am automating a process in Reframework and i need to write data in excel.
Here in process.xaml, i have a workflow SO.xaml where i am excuting a process.
In that process i am declaring a variable having value as 2 and the writing to an excel and then incrementing by 1 .
But when it comes to execute for next transaction it again resets to 2. I even tried limiting the scope.
Can you please let me know what i am missing,

To make sure the counter increments, you will want to increase the scope rather than limit it. I think your scope for the variable forces it to reset to default when it needs to be instantiated at a higher scope.

Hi Anthony,
Even after setting the scope highest it is still resetting to default.
I tried using arguments but still same issue.

Hi @amitkk_84
Whilst you have set the scope to "Create_SO_VA01, have you kept the count incrementer within the sequence?

Also - does the sequence definitely contain more than 1 iteration?

Since i am using REFramework it will call the process more than once.
Yes sequence contains more than 1 iteration

Make sure you’re adding 1 to the counter in the right place in the code as well. Secondly, make sure you’re not resetting the value back to 2 anywhere in the code.

Since i am using REFramework it will call the process more than once.

Correct - Are you trying to iterate this counter so that it starts at the latest value after the process is run again? If so, you will want to make the counter variable an io_argument which feeds back up through the process into the main.

Yes. Thats right
So when the second transaction has started then the counter should be 3 and not 2.
Can you please explain me how to do that since i tried using arguments but facing same issue.
Please find the attachment for arguments used.Variables issue.docx (1.2 MB)

@amitkk_84 if you change the argument type in “Create_SO” and in “Process” to be In/Out instead of In then it should work for you. The reason for this is that you want to consume (In) the data but you also want to update (Out).

Let me try it out

Hello Harrison,
I tried with the in/out arguments but still the same issue.Please find the attached screenshot.
As you can see this is the second transaction and the in_C1 argument is still having value as 2.

Are you iterating in_C1 or counter? you should be iterating in_C1

I am iterating in_C1

And to you have in_C1 set as an in/out argument in “Process” as well?

This is the process screenshot.
I certainly have a doubt that somewhere i might have done a silly mistake. :slight_smile:

If you default a variable with a value, the variable will be set to the default value every time the process is called.

For your situation, which I assume, is writing information to an excel sheet starting from row 2, did you consider storing that information in a config file and reading from there every time the process runs? If the process doesn’t always start at 2, then at the end previous run, write the last value to that config sheet, so that it picks that number for the next run.

The problem is solved by declaring variable in the Main and then incrementing.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.