I have a datatable that consists of 2 columns and could contain a variable amount of rows and it is generated via a query to the database.
01/01/2020 Healthcare Plan Changed
02/02/2020 Dental Plan Changed
03/03/2020 HSA Plan Changed
Now the number of rows in this datatable with a maximum of 6 total rows that contain 6 different things that could change in Column B.
My ultimate goal is to have UiPath look in the datatable for any of the keywords that occured (Dental Plan Changed, HSA Plan Changed…etc) , and if any of of those rows exist, then bring back the associated date into a variable.
Below is the method that I am using, I would like to discuss a potential more efficient method with the community.
1-The Query generated my datatable
2- I place 6 consecutive IF statements that look for particular string in ColumnB using this formula. DATATABLE.AsEnumerable().Any(Function(x) x(“COLUMNB”).ToString = “HSA PLAN CHANGED”).
3- If the statement evaluates as true, meaning that the value exists in the datatable, I then get the datarow from the datatable using DATAROW= DATATABLE.Select(“[COLUMNB] = ‘HSA PLAN CHANGED’”)(0).
4- After that I get the Index of that datarow in that table using DATATABLE.Rows.IndexOf(DATAROW)
5- After getting that datarow index, I then retrieve the date value corresponding to that datarow using Datatable.Rows(IndexVariable).Item(“COLUMNB”).ToString
Is there a more efficient/elegant way of doing this?