I was recently working on a UiPath automation that required creating a structured report from various data sources. The process involved building a DataTable with three columns: Name, Age, and Job.
I created a workflow that involved first creating a new DataTable with three columns: Name, Age, and Job. For the first row, I used the ArrayRow approach and provided only the name “John Smith”. Then, I attempted to add Age and Job information using the DataTable.NewRow method (Age and Job has its own of DataRow), thinking it would update the existing row.
The Unexpected Result
When I ran the automation, the output DataTable looked like this:
The Name value was correctly inserted in the first row of column A, but the Age and Job values were placed in the second row under columns B and C. This wasn’t what I intended - I wanted all three values to appear in the same row.
I want to use ArrayRow for {var1, var2, var3} and then add var4 and var5 because they are from different sequences. I am not sure whether DataRow can also handle {var1, var2, var3} in the same way.
I want to use ArrayRow for {var1, var2, var3} and later add var4 and var5 from different sequences. However, as shown in the attached image, I’m currently using only one variable for ArrayRow, while the real RPA setup has multiple variables.
ArrayRow seems better for homogeneous data, but I’m unsure if DataRow can maintain the sequence of var1, var2, and var3, which is crucial for my report. Thank you!
Use assign activity with datajam.rows(datajam.Rowcount-1)("Age") = "Age value" this way a new row is not created but the data is assigned to the last possible row which is the new row added with add data row in your case
Use array store the values and at last use add datarow with passing the array
I added the first Add Data Row activity to temporarily store email-extracted data in the DataTable for running two sequences: Sequence A and Sequence B. In Sequence A, I record the time of ID deletion, and in Sequence B, I save the deletion time for System B. Since multiple IDs need processing, I use multiple Add Data Row activities.
Please correct me if my understanding is wrong, as I’m still new to UiPath.
Please note that - Whenever you use Add Data Row Activity, it will always add a row and update the value. If you want to update on the same line - Kindly follow below approach
Step 1: Create a variable (ArrayString) of type Array of String and initialize the variable as provided in the below screenshot. Variable type is Array (Of String). Default value is important
Step 3: This is important
instead of adding data row directly, our method should be to add details to above Array of string variable. Use below expression in assign activity for the same. Values same as what you used while adding data row to data table. I have used value as Newvalue here in the below screenshot
Step 4: Instead of second add data row activity, use the same for different values. Idea is to complete the array of string variable matching with the data columns in data table and add this array at the end