Issue with Looping through CSV Data in UI.Vision RPA Macro

Hello UI.Vision RPA Community,

I’ve encountered a persistent issue with my UI.Vision RPA macro that I’m hoping to get some help with. The macro is designed to automate a series of web actions based on data read from a CSV file.
While the macro performs perfectly for a single row of data, it fails to loop through multiple rows, thereby not executing the actions for subsequent entries in the CSV file.

Problem Summary:
The macro is expected to loop through each row of a two-row CSV file, performing the same set of actions with different data each time. However, it only processes the first row and doesn’t proceed to the next row.

Steps Taken and Observations:

Ensured the CSV file is correctly formatted and only contains two rows of data.
The macro performs all intended actions accurately for the first row.
Utilized executeScript_Sandbox with a JavaScript snippet to increment the row index. The incrementation seems to fail, causing the macro to attempt to process the first row repeatedly.
The issue persists even after multiple adjustments to the code responsible for incrementing the row index.
The environment is a dedicated setup with ample resources, and the issue seems to be specific to the looping logic in the macro.

Macro Example (Simplified for Clarity):

{
“Name”: “Automation_Macro”,
“CreationDate”: “2024-1-23”,
“Commands”: [
{
“Command”: “csvReadArray”,
“Target”: “Automation_CSV.csv”,
“Value”: “myDataArray”,
“Description”: “Read the entire CSV file into an array”
},
{
“Command”: “store”,
“Target”: “0”,
“Value”: “myCurrentRowIndex”,
“Description”: “Initialize current row index to 0”
},
{
“Command”: “label”,
“Target”: “startLoop”,
“Value”: “”,
“Description”: “Label for the start of the loop”
},
{
“Command”: “if_v2”,
“Target”: “${myCurrentRowIndex} >= ${myDataArray.length}”,
“Value”: “”,
“Description”: “Check if the end of the CSV array is reached”
},
{
“Command”: “gotoLabel”,
“Target”: “endMacro”,
“Value”: “”,
“Description”: “Go to the end of the macro if all rows have been processed”
},
{
“Command”: “end”,
“Target”: “”,
“Value”: “”,
“Description”: “End the ‘if’ block”
},
{
“Command”: “echo”,
“Target”: “Current Row Index: ${myCurrentRowIndex}, Array Length: ${myDataArray.length}”,
“Value”: “”,
“Description”: “Output the current row index and array length for debugging”
},
{
“Command”: “store”,
“Target”: “${myDataArray[${myCurrentRowIndex}][0]}”,
“Value”: “!COL1”,
“Description”: “Store the first column of the current row into !COL1”
},
{
“Command”: “store”,
“Target”: “${myDataArray[${myCurrentRowIndex}][1]}”,
“Value”: “!COL2”,
“Description”: “Store the second column of the current row into !COL2”
},
{
“Command”: “store”,
“Target”: “${myDataArray[${myCurrentRowIndex}][2]}”,
“Value”: “!COL3”,
“Description”: “Store the third column of the current row into !COL3”
},
{
“Command”: “store”,
“Target”: “${myDataArray[${myCurrentRowIndex}][3]}”,
“Value”: “!COL4”,
“Description”: “Store the fourth column of the current row into !COL4”
},
{
“Command”: “selectWindow”,
“Target”: “tab=open”,
“Value”: “https://www.project.com/login.php”,
“Description”: “Open login page in a new tab”
},

/// The macros actions opens 2 tabs uses the data from the .csv to fill a webform - username and password. 
/// moves to tab 2 which is the col 4 a url. copies and pastes from tab2 to tab 1, blah, blah blah
/// not sure if the actions taken on the macro are effecting the loop interation?


{
  "Command": "echo",
  "Target": "myCurrentRowIndex value before increment: ${myCurrentRowIndex}",
  "Value": "",
  "Description": "Output the current row index before increment"
},
{
  "Command": "executeScript_Sandbox",
  "Target": "var index = parseInt(arguments[0], 10); return isNaN(index) ? 0 : index + 1;",
  "Value": "myCurrentRowIndex",
  "Description": "Properly increment the row index or reset to '0' if the current value is not a number"
},
{
  "Command": "echo",
  "Target": "New myCurrentRowIndex: ${myCurrentRowIndex}",
  "Value": "",
  "Description": "Output the updated row index after increment"
},
{
  "Command": "gotoLabel",
  "Target": "startLoop",
  "Value": "",
  "Description": "Go back to the start of the loop"
},
{
  "Command": "label",
  "Target": "endMacro",
  "Value": "",
  "Description": "Label for the end of the macro"
}

]
}

Request for Assistance:
I am looking for insights into why the loop doesn’t proceed to the second row and how I can resolve this issue.
If there’s an alternative approach to looping through the CSV data or if I’m missing an important step, I would greatly appreciate your guidance.

Thank you in advance for your time and help!

Windows 10
Chrome Version 120.0.6099.218 (Official Build) (64-bit)
UI.Vision RPA 8.3.9

Hi

This seems like a very simple job to do with an alternative command

I recommend that you adapt the macro to the csvRead command

Here info and example
https://ui.vision/rpa/docs/selenium-ide/csvread

Thanks for taking the time.

Id like to think i originally attempted to use the csvRead.

I have reworked the macro several times now. so much, I am not even sure i am recalling the path i took, because i was failing so much.

Which lead me to alternative command csvReadArray.

Maybe i am wrong and ill try it again.

I just figured i created a conflict i wasnt aware of.

Ill make another attempt.

The macro code is very confusing but looks like a simple loop.

You can use the !TIMES function to execute the loops, you don’t need the many lines of code you used

You can create a macro similar to yours with just a few commands so it’s quick and easy to update

Read here info about TIMES command
https://ui.vision/rpa/docs/selenium-ide/times
.
To update the loop number I use this simple trick

  {
      "Command": "store",
      "Target": "${!TIMES}",
      "Value": "!csvReadLineNumber",
      "Description": ""
    },

There are other solution to update the loop number like

{
  "Command": "executeScript_Sandbox",
  "Target": "return Number (${!csvReadLineNumber}) + 1",
  "Value": "!csvReadLineNumber"
},