cancel
Showing results for 
Search instead for 
Did you mean: 
Workflow Hero

Enumerate users in a SharePoint Group

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

0 Kudos
Reply
14 Replies
Workflow Hero

Re: Enumerate users in a SharePoint Group

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

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Enumerate users in a SharePoint Group

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

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Enumerate users in a SharePoint Group

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.

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Enumerate users in a SharePoint Group

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

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Enumerate users in a SharePoint Group

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".

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Enumerate users in a SharePoint Group

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

Accept as Solution Reply
Not applicable

Re: Enumerate users in a SharePoint Group

I agree with Mike M. So you need a Web Service and a Query XML action. In the Web Service you call Web URL/_vti_bin/usergroup.asmx and in the Query XML action you use the following XPath:

/defaultNS:GetUserCollectionFromGroup/defaultNS:Users/defaultNS:User/@LoginName

The steps are described in more detail in this article.

Accept as Solution Reply
Workflow Hero

Re: Enumerate users in a SharePoint Group

Did my suggestion solve your issue? 

0 Kudos
Accept as Solution Reply
Workflow Hero

Re: Enumerate users in a SharePoint Group

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.

Accept as Solution Reply