How To Get A Datatable With Specified Columns Only In UiPath

While dealing with data table operations, sometimes we might want to retrieve only specific columns from it.

How to do that?

dt_New=dt_Original.DefaultView.toTable(false,”Column1″,”Column2″,…)

Note:
Simply replace the “Column1″,”Column2” and so on with your required Columns


Example

Implementation using UiPath :

Let us implement a workflow which takes a “DataTable” and gives us out the “DataTable with specific columns“.

Step 1:
Drag “Build Data Table” activity into the design panel and populate it with some sample data.

UiPath Datatable with Specific Columns 1

UiPath Datatable with Specific Columns 2

Step 2:
Drag “Assign” activity into the design panel and fill it with above-mentioned code.

UiPath Datatable with Specific Columns 3

Step 3:
Drag “Message Box” activity to display the result
(Note: Here we have used LINQ to display the DataTable Instead of Output DataTable

string.join(System.Environment.NewLine, dt_YourDataTable.Rows.Cast(of DataRow).Select(function(row) string.join(“,”,row.ItemArray))))

UiPath Datatable with Specific Columns 4.PNG

Step 3:
Finally!!!

UiPath Datatable with Specific Columns 5.PNG

Click here to download the Source Code…

Hope it has helped you… 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: