Sometimes my column will not have any data and then i need to do something otherwise i need to continue.
I have it like this:
Now it can handle when the rows are empty under “Reg. på plats” but if i get transaction that contains something under “Reg. på plats” i still end up in the “Else” part.
I can see the simple way to achieve is with Try-Catch
I’ll suggest you to use select statement assign —> DT1 = tempDataTable.Select(…).CopyToDataTable <— in Try section.
after that you can have sequence of process of expecting data in it (In try section right after assign)
create system.exeption in catch and put sequence of process of expecting no data in it. (In catch section)
By this bot will able to do further tasks in try itself (when DT have data in it) and handle the exception of having no data in DT with another further tasks in Catch section.
When you use a dt.select, but there are no rows which conform to the formula, it will give you an error saying source contains no data rows.
In your example at the start, you have used the .select method to create a list of rows where Reg… is " ". if there are no rows which conform to this, it will break, not just return a zero.
A way to get around this is to use the filter datatable activity instead, which works in a similar way to the .select method, but will not error when zero is returned. if you do this before your ‘If’ statement, and in the ‘If’ condition have a simple dt.rows.count>0 you should be good to go
String.IsNulOrWhitespace(YourString) is returning false in case of a value is present and value is not “” or " "
it can be used for a check for entire datatable with following statement:
tmpDataTable.AsEnumerable.Any(Function ( r ) Not String.IsNullOrWhitespace(r([Reg. på plats).toString.trim))
This is based on the previous task you helped me with.
Sometimes there is no “ja” in the column “Reg. på plats”
Thats why im looking for a way to use the If statement to look at the datatable and if everything is empty under “Reg. på plats” it should assign 0 to countJA otherwise it should do the “Then” part.
I dont really know I how i should use the things you described.
Start debugging till the point that tmpData is existing
Open watch panel
Copy statement in to the watch expression:
tmpDataTable.AsEnumerable.Any(Function ( r ) Not String.IsNullOrWhitespace(r([Reg. på plats).toString.trim))
an inspect the result true or false
If the statement is working as expected jus copy it into the if statement, that you have shown in the post above. Change for the true case the assignment to tmpData.Rows.Count
I started the debugging and when I saw the tmpData I inserted tmpDataTable.AsEnumerable.Any(Function (r) Not String.IsNullOrWhitespace(r([Reg. på plats).toString.trim)) in the expression place.