How to initialise an array for RPA challenge

Hi all

I’ve seen some colleagues have done the RPA challenge in around 1 second through using just activities in Ui Path.

They way they have done this is by initialising an array with the labels and by telling the array how may rows it will contain, and then by clever use of the selectors and a parallel for each to make the robot fill all the fields in at the same time for each record.

I’m not sure how to write the code (which I assume is in an Activity stage) to initialise the array and tell it, it has 11 rows (1 row of labels and 10 rows of data from the excel file).

Any help or advice on this please, would be much appreciated.

Thanks all
Jordan

1 Like

Array can be initialized based on the type

Assuming you need string array @jordrowley

then ArrayStringVariable = new string(11){}

3 Likes

Fine
using array is a good practice but only when we are sure with the count of values or elements that we are going to store in the array is FIXED
And as a developer we should take that case into consideration, like what to do if the number of elements to be stored and used gets changing
–So to handle that case we can use LIST variable instead of ARRAY
–as list variable can take any number of input at any time and the size it can take is never fixed unless we define it with values (probably we wont mostly)

so its very similar way of using array and list as both are some sort of collections only
–so to initialize a list variable of type string (i use string now for example we can change as per our need)
variable name - list_inputStr
variable type - System.Collections.Generic.List(of string)
scope - global (to whole sequence)
Default value - New List(of string)

or

if we are sure (100%)
that we know what is the size of the array we are going to save then
to initialize a array
variable name - arr_inputStr
variable type - Array(of string)
scope - global (to whole sequence)
Default value -New String(size){}

hope this would help you
Cheers @jordrowley

1 Like

@Palaniyappan fantastic reply as always, which I will mark as the solution, thank you :slight_smile:

Please can I ask about the next stage. I’ve spent the last 30 mins trying to find a selector that will either always highlight the required label (e.g first name) or the field next to the label. I’m really struggling with this. Do you have any ideas?

Thanks
Jordan

1 Like

we can use HIGHLIGHT activity with the selector of the element
or
if we are not sure of the element then we can use FIND TEXT POSITION activity where pass the string as input and we will be getting the UIELEMENT variable as output variable
–now pass that variable as input to HIGHLIGHT activity with the property ELEMENT in the property panel

hope this would help you
Cheers @jordrowley

Thanks @Palaniyappan I will give that a go :slight_smile: Ta!
Jordan

1 Like

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