Counting the full KeyValuePair in transaction item variable

Hello everybody,

I have a transaction item with 35 KeyValuePair. The key value pair is not always filled. There are keys exiting with value null.
Is there a way to count the non-empty KeyValuePair from the transaction item?

With TransactionItem.SpecificContent.Values.Count all pairs are counted, even the empty ones.

I believe in this case you would have to loop through the dictionary and check if the ones with null value. I don’t if there’s an easier way to do it.

TransactionItem.SpecificContent.Where(Function (kvp) isNothing(kvp.Value) OrElse String.IsNullOrEmpty(kvp.Value.toString.Trim)).Count
2 Likes

That’s very useful, I’ll take note too, thanks!

Thank you very much! I can delete a lot of activities with it and everything becomes more transparent.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.