How do i enter elements into the array individually?

In java the command is:

int ar=new int[10];
for(int i=0;i<10;i++)

How do we do this in UiPath?
To state in points:

  1. How do we define size of the array- type String, Integer and Generic Value?
  2. How do we add elements to the array one at a time inside a loop?

Thanking you in anticipation.

1 Like

It’s just - you can use the assign activity to complete the task. If I get time I’ll provide an example but here is a link…

There is also a For Each activity in UiPath just remember to set the object to the correct type (e.g. string, object, etc)


Thanks @richarddenton,
This does answer my question and an example will really be helpful.

Additionally, Could you also guide me to insert the entire row of a data table to an array? Would it be using for each row then iterating through item and adding it as per the link?

You could use

for i=0  to i = max number of columns

Assign currentInfo = dtTable(row)(i).ToString

This will get the particular item for that row and column combination (i.e. cell)

and then simply add it to your array. I would ask though why you need to add info to an array if you already have it in a dataRow format? :slight_smile:

Hi @richarddenton

Can we declare the array size initially in the UiPath before initializing it .

So, i have a workflow that reads an unstructured excel sheet and inserts the data into a data table. However, this happens many times as there are many such sheets. This would implicitly mean many rows in the data table.

Next, i invoke that workflow, and pass the data table as an argument. I need to write each element in different fields of the form. I didn’t know whether each element can be accessed individually outside of a for each row activity and get row item- since the get row item would require variables to be initialized and written into the form individually.

I’m not sure if i could explain it effectively, but if you have any questions to understand it, i could elaborate further. :slight_smile:


Kindly check the example attached.
Main.xaml (7.8 KB)


Thanks a ton! It’s answered all my doubts. :smiley:

1 Like