How to know if a user is on a Sharepoint Group?

Document created by fhunth Champion on Jan 1, 2016
Version 1Show Document
  • View in full screen mode

Many people posted this question and sometime ago there were some external post that dissapeared. So now it will keep safe in this post.

 

 

 

Create workflow variable varUserGroupXML type=Multiple Lines of Text

Create workflow variable varUserGroupNames type=Collection

Create workflow variable varIsInGroup type=Yes/No

 

To make it easy to reuse, create an Action Set action, and label it "Is user in group?"

Put the following within that Action Set.

 

Call Web Service action. Configure it as follows:

     URL: Web_URL/_vti_bin/UserGroup.asmx. Supply necessary Username/PW credentials.

  • Web Method: GetGroupCollectionFromUser
  • Editor Mode: SOAP builder
  • userLoginName(string): Initiator
  • Web Service Output: Specify elements "../m:GetGroupCollectionFromUserResult" > varUserGroupXML

Use the Run Now to verify things work. Query XML action. Configure as follows:

  • XML Source: XML
  • XML: {WorkflowVariable:varUserGroupXML}
  • Output 1: Process using: XPath.
    /defaultNS:GetGroupCollectionFromUser/defaultNS/Groups/DefaultNS:Group/@Name
  • Return Results as: text
  • store result in : varUserGroupNames

Collection Operation action. Configure as follows:

  • Target collection: varUserGroupNames
  • Exists: checked
  • Value: Value (selected from dropdown menu) - (the group name you are interested in) typed in text input
  • Store result in: varIsInGroup

 

Now, the value of varIsInGroup will be a yes/no.

 

You could probably make this cleaner by putting the group name to search for in a workflow variable as well.

Attachments

    Outcomes