Assign strings in a array in for each loop

I am getting a string Variable in a for each loop and want to store in a array to right in a data table using Add Row activity.

Can anyone help me please?

1 Like

Let’s take like we have a string variable named str_input inside the FOR EACH activity
—now being inside that we can mention this string variable in a ARRAYROW property of ADD DATAROW activity like this {str_input.ToString}

—or if we want to add to a collection before add Datarow activity the use a ADD TO COLLECTION activity and mention the collection property as list_input where it is a variable of type System.Collections.Generic.List(of string) defined in the variable panel with default value as New List(of string) and along the item property in Add Data Row activity mention the input as str_input

—so followed by this use Add data row activity and mention the array row property as list_input.ToArray()

Hope this would help you
Cheers @sbala

@Palaniyappan ,thank you thaliva!, but getting an error as below

“Value of ‘String’ cannot be converted to '1-dimensional array of object”

Sorry, am very new to the UI path.

1 Like

If possible can I have a view in how that string variable was mentioned
It should be like this
{str_input.ToString} Which depicts that the Datatable has only one column in it
The syntax to be used in ArrayRow is

Where we need to have exact number elements in this ArrayRow which is equal to exact number of columns in the datatable
Cheers @sbala

Now were we able to get them working
Kindly let know for any queries or clarification
Cheers @sbala

@Palaniyappan ,

attached the screenshot

1 Like

If I know how to create an array by adding element in for each loop, it will help to create an array which is required for datatable.

You were almost done
It’s just a syntax issue buddy
Let’s take an example like if the datatable dt has three columns in it then if we want to pass the value to it through ArrayRow property it should be be like

If we have the values in a string variable then ArrayRow should be like this

So here in our case if we have one column in our datatable dt_ExtractedNotes then the array row will be like

Cheers @sbala

@Palaniyappan, thank you !

Yes, i was trying with {final_String}.ToString instead of {final_String.ToString} . Also I found another way of doing this as well. I will upload the XAML once I do some cleanup.

Thanks for your help!

Cheers @sbala