Thanks for your prompt response. Your answer helps. I have used the "singleRM" variable as a value in the "Store result" field of the "For Each" action.
However, it now gives me an error in the "get collection variable" operations: Index property is greater than the number of items in the collection.
I suppose this is because the Query is not picking any results. I placed a log-history action to give me the coll_AcctName; coll_AccNumber and the result after the query is just a plain blank.
However, the history log before the Query specifies that the "singleRM" variable = Item Propert "RM" (AD\user).
I'm not sure why is the query not collecting the specified fields in the collection variables that I created. That's why the "collection operations" have nothing to "get".
this could be a formatting issue. SharePoint normally stores users with their id in a format like "<userID>;#<userLoginName>" and your filter may need this format for the input to work properly.
Have a look here (see the comments for how to retrieve user id): Inserting an item with web service call (people)
and also here (in case you need the claims encoding): Claims Encoding Values in SharePoint
Hope this helps
Before I have a look, the second log-history action retrieves the same value for "RM" item list as well as for "singleRM" variable. It returns \AD:ruco in both. Is it possible that this is still a formatting issue, like you mentioned?
That's correct, the second query does not return anything. However, the value of "singleRM" and "RM" before the query takes place reads the same in the history log: "AD\ruco". This confuses me because if both values are equal the filter should work and the query should return the values of the other columns in the collection variables.
But isn't "RM" what you query in your first list and save inside a collection variable?
If "AD\ruco" ist the only one in this collection, it may seem like the same value of "singleRM". However, it is still a collection.
I keep trying and trying different ways but it still doesn't do what I want. The issue is as follows:
1) First "Query List" picks all available 'RMs' (Column with 'person or group' type) into collection variable 'col_RMs'
2) "Collection Operation" action removes the duplicates from the variable 'col_RMs' and stores it in 'col_RMs' again. A log in history confirms that the name of each RM appears only once.
3) The "For Each" action picks 'col_RMs' as a target collection and the result is stored in 'item_RMs' which is a "Person or Group" type variable. A log in history confirms that the 'item_RMs' variable and the 'RMs' (from the item properties) values are the same.
4) The second "Query List" action is intended to collect all the accounts that pertain to each RM (item_RM). For that purpose, a filter should say that items should be shown only if "RM" is equal to "item_RMs". However, this filter fails to query any information from the accouts. If I remove the filter, I can get all the accounts - but this includes the accounts of other RMs. Using the filter breaks it down. Not using it defeats the purpose of the workflow because I don't want all accounts to be displayed in the query results. I only want the accounts of each particular RM so they receive an email with their multiple list items.
5) The "collection variable" operations are intended to 'get' the data from the collection variables in the second Query Action list so that I can put them in a "Build a string" action. However, this operation always fails because the second Query returns nothing.
Appreciate your help.
If you query your second list without filter and display the result, how are the names of the RMs saved in this list?
Doest the pattern match your "item_RMs" pattern? If it does, the filter should work. If it doesn't you need to prepare your "item_RMs" to match the pattern.
I do not extract the names of the RMs on my second query. However, to answer your question I have added the "RM" field to the query and stored them in a different collection variable: "col_displayRMs".
The names appear as follows: AD\ruco; AD\mger
This matches with the "item_RMs" pattern completely. They are equal. However the filter results in the query not returning anything.. I really wonder what is going wrong here!
I would need to test this myself, but not sure when i will have the time.
One other idea: It looks like you have multiple RMs in your column. This means a "is equal to" filter won't work but a "contains" could do.
("AD\ruco; AD\mger") is equal to ("AD\ruco") ==>FALSE
("AD\ruco; AD\mger") contains ("AD\ruco") ==> TRUE
Could this be the problem?