This should surely be a simple task, but since the recent change to the Object model I've found no easy way.
I have a list with 2x columns: a city code (SYD, MEL, etc) and an email. Each row on the list has a unique city code. The goal is to enter a city code and then have the WF query the list and pull back the corresponding email and store it in a variable. This was super simple prior to the change to the Object model. I won't go over that however; I'll explain what I see now.
Add a Query a List action: set the conditions to only pull back results where the Code on the form matches the Code on the list. The output is an Object: a special kind of collection that includes number of items returned, a sub-collection of Item IDs and a sub-Collection of the Items themselves (that includes al fields).
Now I know the Object has a single Item - but how do you extract column 2 (email) from that Item? You can't use 'Get item from collection': you can set that to look at the sub-collection of Items in the Object but then you need store that data in text value. All the fileds for that Item in a long string with field names, etc. as CSV. You would then need to use string operations to try and pull that apart.
The only option I can see is to use a 'Loop for each' action that allows you to target the sub-collection of Items. That seems a waste since I know the Index of the item I want and also know the collection only has one item, but whatever. The next problem then: say you put a 'Set a variable value' action in the loop to take the variable 'Loop for each > current item > email' and store that in a new variable (say txtMail). Turns out that variable doesn't hold a value once you exit the loop. So again, that doesn't work.
The only way I have found to get a field/column value from 'Query a list' is to create a new Collection variable, put an 'Add item to collection' action in the loop, and then outside the loop 'Get item from collection' That's 4x actions (Query a list, Loop for each, Add item to collection, Get item from collection) and multiple varaibles just to get a single field value from a specific item on a list.
Please someone tell me I've missed something here and there is a simpler way.
Best answer by WouterT
View original