Skip to main content

Hi Folks,

 

Am pretty stumped on retrieving values from a collection, which has been created through using the Query List Action...

 

Here's the example.

 

Am using Query List to select one row of data from a Lookup List, which then is saved so say COLLECTIONA

 

Lets say the column fields are called columna, b and c and in each of these is stored a value called valuea, b and c

 

The log to history shows this as:

 

/{"COLUMNA":"VALUEA","COLUMNB":"VALUEB","COLUMNC":"VALUEC"}]

 

I have three separate variables which must hold each of the values, e.g. Var1, Var2 and Var3.

 

How do I extract each of the Values from the Collection so that ValueA goes into Var1, ValueB goes into Var2 and ValueC goes into Var3?

 

Am sure this has been done tons of time before but cannot find a definitive answer - please help!

 

Thanks

 

G

Hi, in your query list action you have choose "Single output", so, in result you have an collection of dictionary. If you you choose "Separate output per column", in result, you will have 1 collection per field.



 



To extract values of your collection of dictionary, you need to use the action "Get item from a dictionary".



In Dictionary parameter, set you collection (result of the query list)



In item name or path, set : 0/COLUMNA



In the output, set : VarA



 



and do the same for each of you field. 



 



This example is just to get the first value of the result of you query.



If your query return several items, you can use a foreach to iterate throw all the dictionary in your collection.



 



For you understanding : 



{"COLUMNA":"VALUEA","COLUMNB":"VALUEB","COLUMNC":"VALUEC"} => this is a dictionary



[{"COLUMNA":"VALUEA","COLUMNB":"VALUEB","COLUMNC":"VALUEC"}] => this is a collection of one dictionnary



[{"COLUMNA":"VALUEA","COLUMNB":"VALUEB","COLUMNC":"VALUEC"},{"COLUMNA":"VALUEA","COLUMNB":"VALUEB","COLUMNC":"VALUEC"}]  => this is a collection of two dictionnaries



 



If you use "Get item from a dictionnary" action on a collection, to get a value, you need to use a path like : 0/COLUMNA (to get the value of COLUMNA of the dictionnary store at index 0 of the collection. If you use 1/COLUMNA, you will get the value of COLUMNA of the dictionnary store at index 1.)



If you use "Get item from a dictionary" action on a dictionary, you can simply use COLUMNA in the path of the action.



 



 


Thanks :)



 



Silly me, should have set to Collection output instead of Dictionary, makes things a lot easier!



 



Cheers



 



G


It depends, personally I prefer using dictionary (you just use 1 collection of all the result and not X collection for each column)

Reply