Enumerate users in a SharePoint Group


Badge +3

Out site collection template includes numerous SharePoint groups defining project roles, most of which are empty to start, which are tied to Nintex workflows (Nintex Workflow 2013.) We do this for the fairly obvious reason that we do not know who will be in these groups until the project is set up and the site collection is provisioned.

The workflows typically assign tasks to the group, which does not allow our users to filter the task lists for [My] to get a list of what they need to act on. I would like to enumerate the user(s) in the groups and assign the tasks directly to those users. I was hoping to use for-each operator, but it works on a collection, not a "group".

Has anyone accomplished this, or should I classify it under recreational impossibility?

Thanks


12 replies

Badge +11

You can create a workflow variable with a people/group type and set that variable equal to the group. Then you can enumerate it.

Badge +11

Or you could have the group be set to a collection workflow variable and enumerate that.

Badge +3

In the case of enumerating a variable set to the group, can that be done with the for-each operator? From what I saw, it needs a collection. Which leads to the second option, how does one assign a group to a collection?

I had been thinking along the lines of your suggestions and did not see obvious ways around these issues. I have not yet RTFM'ed this, so excuse the ignorance.

Badge +11

If you set it to the collection variable you should be able to.....try it....

Badge +3

So, I create a workflow with three variables:

  • theUser (person or group)
  • theGroup (person or group)
  • theCollection (collection)

Step 1: Assign a specific group to the variable "theGroup"

Step 2: Collection operation, "Add"  Value "theGroup" to target collection "theCollection"

Step 3: For-each "theUser" in collection "theCollection" ...send email notification

END

Error.

Failed to send notification. Cannot get the full name or e-mail address of user "#Project Members".

...#Project Members is the group assigned to the variable "theGroup".

Userlevel 5
Badge +12

You could use a webservice to call the UserGroup.GetUserCollectionFromGroup which will give you an XML that contains all users in that group.  You could then parse the XML into a collection, and use a For Each on that collection to iterate through it and assign tasks to each member.

Hope that helps!

Mike

Userlevel 5
Badge +12

Did my suggestion solve your issue? 

Badge +3

I'm sure it will, but I have not moved on that. I will need to learn a bit more about Nintex, and how best to break out reusable bits like this. I only just started working with both Nintex and SharePoint a few months ago.

The immediate need is to get a very complex and long workflow broken into several more digestible bits, because on occasion, it fails and there is no good solution to start it again.

Badge +6

Wait a minute, there are usually views such as By My Groups that filter both direct and group assignments. Don't these work for you? In this case the CAML view query should include a Membership operator. See CAML Filter for Current Group Membership | Marc D Anderson's Blog  for example.

You could query for items with a query containing such operator without enumerating group members.

Badge +3

Thanks. I will look into this. That may well get me 90% there. We do have one field that will be assigned to multiple individual users (selected from a group) which may give us some issues, but I bet that can be resolved.

Badge +3

For cultural reasons, we do not use tasks. It was felt that it was too much work to have people open the task, go to the item or file, add the comments and then mark the task complete. We send an email notification, people add their comments to the item itself, and then change a status field to indicate that the next bit of work needs to be done.

Advantage: the item history is very complete and gives end users a good view of what happened.

Disadvantage: it is almost exactly not how SharePoint works.

Badge +11

A lot of the tasks that you are listing that you feel are too much for the users to do can be done automatically in Nintex. For example, marking the task complete, change a status, send an email notification.

Reply