How to store the data in REF

Hello, I’m encountering an issue related to the REF.

My goal is to send an email at the conclusion of the REF process, containing all the information that the robot has discovered. For instance, within the process section, I have a variable of type ‘int’ whose purpose is to increment by 1 with each iteration, as there is new data to process from ‘gretTransactionData.’ Ultimately, the email should read something like this: "The robot has found (variable) books.

But every time the robot iterates because there still data to process, the information stored in the variable is deleted. So the email text is always “The robot has found 0 books.”

It looks like we have logical flaw in the workflow, do you mind sharing the workflow?

Sorry but i can’t share the workflow

Hi @Carla_Munoz

  1. You need to initialize the variable in initialization block instead of process xaml.
  2. Check that argument’s direction, you have to give in/out to hold the increment that variable value (if your using multiple xaml’s)
1 Like

Check if you are resetting the variable somewhere - you might have something like this

booksCount = 0

@Carla_Munoz

no need to create the an extra variable

create an argument as in_TransactionNumber as the name which i mentioned

and map TransactionNumber variable

as in REF no need to create an extra variable for increment purpose

Cheers

1 Like

Fine

the reason why the variable is being deleted is because the REF process is restarted after each iteration. This means that all of the variables in the REF process are reset to their initial values.

To fix this issue, you can use a global variable to store the number of books that the robot has found. Global variables are not reset when the REF process is restarted, so they can be used to store data that needs to be persisted between iterations.

Something like this

`// Create a global variable to store the number of books that the robot has found.
GlobalVariable numberOfBooksFound = 0;

// In the REF process, increment the numberOfBooksFound variable by 1 for each book that is found.
numberOfBooksFound++;

// At the end of the REF process, send an email with the number of books that the robot has found.
SendEmail(“The robot has found " + numberOfBooksFound.ToString() + " books.”);`

Or u can prefer using queues where add the data first and pick them one by one so that new item will be picked without issues

Queues are not reset when the REF process is restarted, so they can be used to store data that needs to be persisted between iterations.

Hope this helps

Cheers @Carla_Munoz

1 Like

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