Add string variable to data table on row 0 and column 0

Please see the attached image. I’m new as you can probably tell but I need to Add string variable value to data table on row 0 and column 0. I have a string variable with a text value I need to add to row 0 and column 0 of the data table in image


The expression be like this in assign activity
row(0) = yourvariable.ToString

Cheers @rohangroombridge

Thanks. Next question is how to i put the variable value on row 0 column 1?


1.First create a Build Data Table and maintain the columns you want and store it in a Data table variable Dt.
2.assign the text value to a variable.
3.use Add data row and assign the values in array list into Data table Dt.

A Manohar

1 Like

May I know your requirement please
Cheers @rohangroombridge

It would be like this
row(1) = yourvariable.ToString

Where row(columnindex) = yourvariable.ToString

row is a variable from For Each row activity
Cheers @rohangroombridge

Thanks all. This is i have is the value in my string variable is changing because i have to have it in a for loop. Each iteration the value changes and each iteration must parse the value to the next row 0 and next column index until the column index hits 3 then it must go down the next row. I hope im making sense?

HI, Thank you. I am sorry but im usure how i use your mentioned workflow. in an assign? how do i do that?

I think I m not clear still
Can I have an example
Cheers @rohangroombridge

No problem. See image below. This is example text data i am iterating through. the output is a string type variable. my for loop goes across the first row and then across the second etc…


as the output is a string variable i need to then input that to a data table but across the first row then the second etc…



use the above mentioned method ,you will get the results.
in For each loop
use Add Data Row ,in array list pass the variables

A Manohar

Hi mate, I’m so sorry but I am confused how that will work. My output from my already made for each will always change every iteration so how will your array list work because each of your var variables will have the name variable.

So we have two datatable and we need to get from one and insert into another right
Cheers @rohangroombridge

Sorry if I’m confusing. All I have at this stage is:

For loop that outputs text and stores into a string variable. The for loop is a part of a dynamic selector used on our web app. I have a get text activity retrieving text data. The output of the get text is stored in a string variable.

My workflow is currently:
For each
Get text (dynamic) (output always change each iteration of the for each)

Then I need to upload the get text output to a data table but in a very organised way. The first output of get text next to go to row 0 column 0 and then the second for loop iteration would have to input the get text output on row 0 column 1 until the for loop hit the iteration value of 3. Then it needs to put the next iteration to the next row and move along the columns

1 Like

I hope that helps?

Hope these would help you resolve this
—hope you are in for each loop
—after get text use a assign activity like this
counter = 0
Where counter is a int32 variable

—next to this use a WHILE LOOP leith the condition like this counter < 3
—inside the while loop use a assign activity like this
Yourdatatable.Rows(rowcounter)(counter) = yourgettextoutput.ToString

—next to this while loop (while still being inside the for each loop) use a assign activity like this
rowcounter = rowcounter + 1

Where rowcounter is a int32 variable with default value as 0 defined in the variable panel

Kindly try this and let know for any queries or clarification
Cheers @rohangroombridge

Thank you. I’ll let you know tomorrow how it goes when I’m back in the office. May I ask, what does counter in (rowcounter)(counter) refer to? The column? Does your mentioned workflow input the data across each cell on row 0 until it hits the limit?

Counter refers to columns
Cheers @rohangroombridge

That’s great thank you. For some reason I had and a sign but I had it like datatable.rows.add()()

Not sure why I had the .add