Printing Dictionary Values

Why is it that i can’t print the values of a Collection of Dictionary on any of the print activities? How can i print the values if so?

Thanks

Hi @Luis_Fernando,

One way is using loop, you can use a for each row to extract the values.

Thanks

1 Like

Hello @Luis_Fernando,

For example, If you read an excel that contains column A: Name of something, and in column B the value of column A. Such as Config.xlsx file from Reframework uipath template.

Then, if you read the sheet, you can do for each row in dt → Assign act: myvar(row("Column A ").ToString) = row(“Column B”).

After that, imagine that in column A in second line there is the word: MyDog

Then in log message use: myvar(“MyDoc”) and the output will be the value in second line in column B

1 Like

Hi @Luis_Fernando,

There can be many ways to do this. Here is what I usually use.

  • TestDictionary.Keys returns array
  • Iterate through the array using For Each activity
  • Use the Key as the key name and TestDictionary(Key.ToString) as value
  • Optionally, I use the index value in the for each, for debugging purposes

So the expression would look like this.
"Index value "+Index.ToString+" Key : "+key.ToString+" with value : "+TestDictionary(key.ToString)

This method should work for most native variable types like string, int, datetime, boolean etc. But if your Dictionary holds any custom variable type (for example, UiElement) then you will need to change this approach slightly.

Here is the sample file for you to try:
PrintDictionary.xaml (7.4 KB)

Hope this helps you and others.

2 Likes

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