Skip to main content
Question

Access multiple values in Dictionary variable

  • October 9, 2022
  • 8 replies
  • 1617 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+22
  • Most Valuable Pathfinder
  • 2692 replies
  • October 10, 2022

Hi @Rishav Pandey​ ,

 

Checkout below tutorial, hope this helps

 

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


  • Author
  • Cadet | Tier 2
  • 5 replies
  • October 10, 2022

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.


Forum|alt.badge.img+4
  • Navigator | Tier 3
  • 27 replies
  • October 11, 2022

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"


Forum|alt.badge.img+4
  • Navigator | Tier 3
  • 27 replies
  • October 11, 2022

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?


Forum|alt.badge.img+4
  • Navigator | Tier 3
  • 27 replies
  • October 11, 2022

@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
  • 5 replies
  • October 11, 2022

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
  • 5 replies
  • October 11, 2022

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


Forum|alt.badge.img+22
  • Most Valuable Pathfinder
  • 2692 replies
  • October 11, 2022

Hi @Rishav Pandey​ ,

 

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