Skip to main content
Question

Access multiple values in Dictionary variable

  • Oct 9, 2022 1:49 PM UTC
  • 8 replies
  • 1851 views

I have a dictionary variable such as

Dict1 =

{"Employee1":"1234","B+",Senior"

"Employee2":"4321","AB+","Junior"}

 

How do I access each value under each key from the variable through the Bot?

 

8 replies

Forum|alt.badge.img+11
  • Most Valuable Pathfinder
  • Oct 10, 2022 5:34 AM UTC

Hi @Rishav Pandey​ ,

 

Checkout below tutorial, hope this helps

 

https://www.youtube.com/watch?v=YsRP1_LWEt8/p>


  • Author
  • Cadet | Tier 2
  • Oct 10, 2022 7:33 AM UTC

No it doesn't. I know how to access values and keys when there is one value per key. In my case I need to access multiple values per key.

Any help is greatly appreciated.


  • Navigator | Tier 3
  • Oct 11, 2022 2:30 AM UTC

You will have to invoke each key as required.

If you are trying to assign 2 keys in a single string you can say something like:

 

Example: "$dicExample{Employee1}$ is a $dicExample{B+}$ Dev"

Output: "1234 is a Senior Dev"


  • Navigator | Tier 3
  • Oct 11, 2022 2:32 AM UTC

In a dictionary there is only ever one key per value (Key Value Pair).

 

I can see now your keys are Employee1 and Employee2?

 

What would the output value of these keys look like?

Are you able to print them in a message box, and show the output?


  • Navigator | Tier 3
  • Oct 11, 2022 6:10 AM UTC

@Rishav Pandey​ 

 

I got it to work, here's what i did.

  1. Make sure you assign your dictionary with sub-type Anyimage
  2. Assign your list to a list variable and then you should be able to use itimage

  • Author
  • Cadet | Tier 2
  • Oct 11, 2022 6:17 AM UTC

Yes you understood it correct.. Employee1 and Employee2 are the Keys here and everything else is the value under it's respective key.

 

My expectation is that the command "$Dict1{Employee1}$" at least returns the list stored under the key. Such as "$Dict1{Employee1} in a message box should give the output as 1234,B+, Senior."

 

But in reality here's what's happening.

  1. When I try to put the command $Dict1{Employee1}$ in the message box, it gives an error saying expecting 'String' received 'ArrayList'
  2. When I try to use the get command of Dictionary Action, I receive the error saying class com.automationanywhere.botcommand.data.impl.ListValue cannot be cast to class com.automationanywhere.botcommand.data.impl.StringValue (com.automationanywhere.botcommand.data.impl.ListValue and com.automationanywhere.botcommand.data.impl.StringValue are in unnamed module of loader java.net.URLClassLoader @244111e1)

 

There seems to be no way I can extract the list stored under a particular key. It is possible in various other programming languages. But in AA it seems to be glitching out.


  • Author
  • Cadet | Tier 2
  • Oct 11, 2022 6:44 AM UTC

Whoaa.. This is actually working.. Thank you so much man..


Forum|alt.badge.img+11
  • Most Valuable Pathfinder
  • Oct 11, 2022 6:54 AM UTC

Hi @Rishav Pandey​ ,

 

You are right, can you try with custom build DLL or python?