Filtering not working if a field is blank and Datatable.Select is faulting

Hello,

I’ve updated to UiPath Studio 2019.8.0 and I’m trying to filter a datatable by 4 fields and if one of the fields is blank, the filtering doesn’t pick that record and it should. I’ve also tried using datatable.select and in this version of Studio is faulting and which worked perfectly fine in a previous version.
Here is what I tried so far:

  1. Filter1

  2. Assign:
    tmp_FilteredProcessedData = dt_OnboardingDataProcessed.Select("[Onboarding Status]=’" + row(“Onboarding Status”).ToString + “’ And [First Name]=’” + row(“First Name”).ToString + “’ And [Last Name]=’” + row(“Last Name”).ToString + “’ And [Resource enterprise ID]=’” + row(“Resource enterprise ID”).ToString + “’”).CopyToDataTable

  3. Assign:
    tmp_FilteredProcessedData = (From line In dt_OnboardingDataProcessed.Select() Where line(“Onboarding Status”).ToString.Equals(row(“Onboarding Status”).ToString) And line(“First Name”).ToString.Equals(row(“First Name”).ToString) And line(“Last Name”).ToString.Equals(row(“Last Name”).ToString) And line(“Resource enterprise ID”).ToString.Equals(row(“Resource enterprise ID”).ToString)).CopyToDataTable

I want to mention that, for example, field “Resource Enterprise ID” is sometimes blank and the filter at point 1. and 2. doesn’t pick it up and it works only when all 4 fields are filled.

Point 3. was working fine even with the blank field before the update, now is faulting. Also point 2. is faulting.

Any suggestion how to solve it?
Thanks!

@Alinutza13 -> What output is coming here ??

What do you mean? I already mentioned what happens.
Point 1. is not returning anything if one of the fields is blank (the exact record with 3 fields filled and 1 field blank exists in the datatable I’m filtering) and points 2 and 3 are faulting “The source contains no DataRows” so I’m assuming that the Select is also not returning the record.

Before updating to the last version of Studio I was using point 3. which worked perfectly.

Hi @Alinutza13
Have a check on your filter configuration.
If on or more fields are empty - is a indicator to use OR instead of AND
explore the opration options - maybe “is not empty” will work better for you
ensure the keep/remove option is set accordingly

Kindly note:Checking if a string is null or empty or only whitespace can be done with function:
String.IsNullOrEmpty(“stringvar”) / String.IsNullOrWhiteSpace(“stringvar”)

Thanks!

I already did that, but I wanted to have a filter working even if a field is blank and not checking if that field is blank or null before filtering :smiley:

I need to filter the datatable on 4 columns and when one of the column has no value the filtering should return the record.
Example:
Status | First Name | Last Name | Enterprise ID
1 | John | Doe | john.doe
3 | Jane | Doe |
1 | Abc | | abd.def

I have a loop from where I get the values and I need to filter on the 4 columns, but if from the loop I have Enterpride ID empty, even though in the datatable the record exists, the filtering is not returning the record.

Hi @Alinutza13

Use Dt.Select("[Status]<>’’ and [First Name]<>’’ and [Last Name]<>’’ and [Entreprise ID]<>’’").CopyToDatatable()

Thanks
Ashwin S

Thanks, but I need also the record with the field blank.

From the loop I have the values: OnbStatus, FirstName, LastName and EnterpriseID and if one of these fields is empty the activity “Filter Datatable” or any dt.select is not working:

  1. dt.Select("[Onboarding Status]=’" + OnbStatus + “’ And [First Name]=’” + FirstName + “’ And [Last Name]=’” + LastName + “’ And [Resource enterprise ID]=’” + EnterpriseID + “’”).CopyToDataTable

  2. (From line In dt.Select() Where line(“Onboarding Status”).ToString.Equals(OnbStatus) And line(“First Name”).ToString.Equals(FirstName) And line(“Last Name”).ToString.Equals(LastName) And line(“Resource enterprise ID”).ToString.Equals(EnterpriseID)).CopyToDataTable

I need a solution to work everytime and not checking whether a field is filled or not, I need the exact match on the values provided.
I already mentioned that the last option (point 2. above) worked fine before updating Studio to the latest version.

To explain the whole context: I have 2 datatables: 1 datatable with 16 columns and 1 datatable with 5 columns and I need to remove from the first datatable the rows that have a match in the second datatable on 4 of the 5 columns.