In the following article, I am going to present to you how to work with DataTables in UiPath. Here are the topics that I am going to cover:
- Create new DataTable
- Display the DataTable content
- Add new DataRow to DataTable
- Update specific DataRow
- Delete specific DataRow
First, let’s create a new project called DataTable Operations.

All operations are performed inside a Sequence. So, let’s add a new sequence and rename it as DataTable Operations.
Create new DataTable
Select the + button to add a new activity to the sequence. You can also press Ctrl+Shift+T. Search for Build Data Table and select the activity.

To define the columns and rows go on and select DataTable.

By default, two columns and two rows are displayed. In this example, I am going to create a Customer DataTable with 3 columns Id, Name and Email address. Also, I am going to add 4 distinct rows. Now let’s configure the columns.

Because I decided to edit the first column (which was string type), a warning message can be visible at the bottom of the window.
Data Type has changed. All data from this column will be lost.
I am going to do the same for the remaining columns Name and Email.

In the end, the DataTable will look like this:

Save everything in a DataTable variable. Go to properties, select the Output DataTable and press Ctrl+K to create a new variable. Name the variable customerDT.

Display the DataTable content
Add Output Data Table activity. Search for the activity and add it after the Build Data Table.

To configure the activity, go to properties and set the Input as customerDT. For the Output create a new variable called customer (String data type).

To visualize the content of the customer DataTable variable I used a Message Box activity.

Add new DataRow to DataTable
To perform the first DataTable operation search for Add Data Row activity and add it right after the Build Data Table.

Go to properties and select ArrayRow. In the new Expression Editor window type the following:
{nothing, “Jerry”, “jerry@mail.com}
The first value of the array is nothing because I have configured the Id column to be auto-incremented. The other values represent the remaining DataTable columns Name and Email.
Also, select customerDT variable as DataTable.


Update specific DataRow
To update the value of a DataRow I am going to perform 2 assign operations. First, I am going to identify a specific row using the Select method (where Id = 3), then I am going to pick the Name column and assign it a new value.
customerDR = customerDT.Select(“Id=3”).FirstOrDefault()
customerDR(“Name”) = “The name was recently updated”


Delete/remove specific DataRow
Search for Remove Data Row activity and add it after the Assign activities.

Go to properties and set the DataTable as customerDT. Then set the Row. On the new Expression Editor window type the following:
customerDT.Select(“Id=2”).FirstOrDefault()
I am using the same Select method to uniquely identify the row I want to delete.

The second row was deleted.

Conclusion
UiPath provides out of the box functionalities to manipulate DataTables. From this article, you learned how to create a new DataTable and how to insert default values. Secondly, you learned how to insert a new DataRow to an existing DataTable. Thirdly, you learned how to update the values of a specific DataRow. And the last one, you learned how to delete a DataRow. Now, after you mastered all these operations, you can build powerful and complex automation using DataTables.
Download the solution
Click on the button below to download the source of the demo (DataTable Operations).