VB Apps: Add row to Datatable

Hello Together,

we have an application where the user creates a datatable with 5 columns.

In a second step the user types into 5 app variables and then we want to add these variables as a row into the datatable. The user can iterate and create again 5 variables to add.

We have seen the documentation with the function add row but do not know how to apply it because we can’t create an app variable with the type Datarow and do not know how to convert an array to Datarow.
Apps - Custom VB functions (uipath.com)

Thank you for your help!

You can have a table and you can have textboxes for 5 variable and then on a button click add these 5 variable to the table

Yes, thank you! I am that far but now I do not now how to add the variables to the table.
My intuition was to use the set value formula: Dt = dt.AddRow(row)

Dt = dt.AddRow({“1”,“2”}) but that did not work.

I also tried:
Build dt2 with values “1”,“2”
Dt = dt1.AddRow({dt2rows(1)}) I did not get an error but the data was not transferred to the datatable.

Therefore, I really don’t know how to set the formula in the button. Do you have an idea? :slight_smile:

addrow.uiapp (75.9 KB)

Check if this helps?

1 Like

It works but it overwrites the existing data in the data table. What changes can be made for that? @Shiwangi_Mishra

1 Like

Hi… I am not sure about your requirement but if you want to keep the data in the table one way is to have a process running which takes text values and table datasource as input and return the table data as output which will include the values added.

Thank you! But what we are looking for is the same as @Parth_Doshi described.
We would like to add more than one data row.

First, we build a datatable as you did in the workflow.
Second, the user enters the variables in the textboxes.
Third, the user adds a data containing the variables row to the existing datatable.

In a next step the user can repeat the steps 2 and 3 and input different data in the textboxes and add those as a data row to the datatable.

Using .addrow the error is always that .addrow is not a datarow.
image

Try the same thing by calling a process on button click and sending text values and datattable as input.

Ok yes, that works but that is not so feasible for our use case.

I think I will use another method and instead of datatable, we will work with concat strings or list items.

but for other use cases it would be nice to have the datarow type in Apps!

it will also simplify to add the data by column name reference!

1 Like

Linking to another post about same issue.
Efficient way to add row to a datatable in Apps - Help / Apps - UiPath Community Forum