Skip to main content

I have two lists,

List A contains an a uniqueAppliation ID (single line string) and a related user (person) and a flag (Yes/no)

List B has two columns a user (person) and count of uniqueApplication IDs (single line string).

Currently I query list A filtering on "related user" <> null AND flag = Yes, this returns a collection of strings representing the users. The format is an mixture of characters domains and staffID in short something like xxxDOMAINstaffID

Subsequently I remove duplicates from the collection.

Next I would like to, "for each" item in my collection, to count how many uniqueApplication IDs there are in list A for this user.

finally I would like to populate List B with items that do not already exist in the list B. (The idea beeing that as my application ID register linked to a person updates and changes, my distinct user list will evolve but not contain any duplicate users)

My problems are:

1) I can not filter list A "users" based on the results from my query of "users" in list A

2) I can not look up users in list B either (to ascertain that I don't add duplicates) as the return from the look-up is not usable as idetifier.

I have concluded that it appears the only "filter" I can apply querying a list using users (person), is display name. unfortunately display name is not unique....

What shoud I do?

Good day Jan,

Is this list in a collection?  Are you saying that you are currently getting your unique list from List A? 

For you count operation you could use the Collection operation with the count option to get a count value on list A.

For list B, I will use a For each action looping through List B 1 by 1 with a For each inside  looping through list A 1 by 1 and inside the second For each I will put a run-if to check whether or not the value is in there.  You will have to set a flag = False and step through all the records at the end outside of the inside for each loop have a another test.  If the flag is still false then add the record. Here is an example. Sorry for the colors, its purely for readability.

199509_WF example.png

Kind Regards,


Thank you for the reponse!

I can't seem to select a (sharepoint) list as the base for a "for each" action - I can only do that on collections.

My lists are both sharepoint lists, list A is an application registry mapping an application to an individual and containing flags for filtering the list into certain "application groups".

The second list(a sharepoint list) are the "distinct" set of users (i.e. no duplicates), and a count of how many apps they have each.


Hi Jan,

Is list B (the set of unique users and application counts) being used for anything else, or is it just used to track the number of applications for each unique user?  There might be a simpler approach to this, but I wanted to make sure I understood the intended use case first.

Thanks!

Brian


Morning Jan,

You can not work in a for each with the list.  You first have to use the Query list action and save the values to a collection.  After that you can use the collection in a for each loop.  I usually just read the list ID into the collection

So that will be a step before the For each. Create a collection, i.e. colListA and colListB.  Then the first step inside the for each loop I use a query list again but this time I create the variables for the list columns that I want, i.e. currentName, currentUSerID, currentAppcount, etc. and these with be specific to the current current List ID in the For each action.

199609_pastedImage_1.png

199613_pastedImage_2.png

199614_pastedImage_3.png

To perform the count you can add a math operation inside the inner For Each loop that counts the instances and then add it to the existing user current app count. 

That is just some information on the collection vs list for a for each.  Let  me know if I need to explain this further.  And also please answer Brian for some further clarification.

Thanks


Thank you for these clarifications.

My second list is used to drive task creation on person by person level, so that each person don't receive one notification for each application they are responsible for.

I.e. I have a new set of workflows for that list, the key is that out of a set of people (with many duplicates) I get a distinct list where each name only appears once...

// Jan


Reply