Validation error passing dictionary value to another workflow

Hello I have a dictionary (of string, object) where key is a string and value is integer. I got the dictionary working (thanks to people who helped me here, and I tested it)

I’m using a for each to pass the value of each key to another workflow, but I got validation error saying option strict disallowing late binding. I get the same error if I use cint(item.value). Can someone please help?


Try using Convert.ToInt32(item.value)


From the beginning, create a dictionary of (string, int32)


Don’t post things multiple times. This was already answered in the other post.

CInt(item.value) also works but it might need to be CInt(item.value.tostring)

1 Like

I tried both but still got the same validation error. When I typed item. I don’t see value as one of the properties but the dictionary works as I tested it using (dictTest.ElementAt(0).Key).tostring + (dictTest.ElementAt(0).Value).string in a message box…


Perhaps you should set KeyValuePair<String,Object> at TypeArgument of ForEach activity as the following.



thanks! but now I’m getting a different error after changing the typeArgument…tried to change the dict to of string, int32, but got the same validation error…


You need to use not Dictionary<String,Object> but KeyValuePair<String,Object> at the TypeArgument. Can you modify it?


oh yes!!! it works now!! thanks so much @Yoichi again for helping me out here!!

1 Like

For Each item in Dict - what is the For Each TypeArgument set to?

Assuming it’s set to string as it should be, then item represents the key but the right side needs to be Dict.Keys. So to get the value you do Dict(item).ToString and if you need it as an integer you do CInt(Dict(item).ToString)

Thanks Paul! It’s my first time using dictionary in UIpath so now I learnt that I need to set the type argument properly. So much appreciated for your time!

1 Like

Dictionaries are fantastic. I use them for many things. As you see here, there are multiple ways to get at their values. And the SpecificContent dictionary is the key to Queue Items (Transactions).

I visualize a dictionary like this, let’s call it myDict:

Name : Paul
City : Miami
Country: USA

Assign myDict(“Name”) = “Tom” – to change the Name
myDict(“City”).ToString – to get the value of City

myDict.Keys – gives you an array {“Name”,“City”,“Country”} which you For Each through
myDict.Values – gives you an array {“Paul”,“Miami”,“USA”} which you can For Each through

It’s important to understand the “of xxxxx, zzzzz” part of a dictionary. Usually you’ll want Dictionary(of string, object) - this means the key (ie Name, City, etc) is a string. But the value is an object so it can be anything (string, int32, boolean, etc)

One time I even did a Dictionary(of string, and used a dictionary to store a bunch of datatables I needed to interact with.

1 Like

Thanks so much Paul for the details. This is so useful, I’ll definitely read more about dictionaries!

And wow i just want to add I’m amazed that you can even do datatables in dictionaries!

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