How to check if you are a member of a specific group within an InfoPath Form?

How to check if you are a member of a specific group within an InfoPath Form? It is not as difficult as you expact. I do not reinvent the wheel so please have a look at http://jaliyaudagedara.blogspot.in/2011/05/getting-current-users-sharepoint-group.html for the implementation of the neede data connections. I just want to show you how to use this modified data connection to get the right result.

So what we want to achieve is to open a InfoPath Web Form and display a red box when we are not a member of the group “Target Group MMC” and a green one if we are a member.

The structure we need looks like this:

  1. A group for the red message: NotAGroupMember
  2. A group for the green message: GroupMember
  3. A boolean for easier implementation of the needed functions: MemberOfTargetGroup

So have a closer look at the red group. There is only one formating rule used. If the condition is true then it hide the red section. The condition is true if MemberOfTargetGroup is true. On the other hand the green group is hide if MemberOfTargetGroup is false.

 

But how does it work that the MemberOfTargetGroup knows that you are a member of a certain group and also recognized that after a while when something is changed and you are no longer a member?

 

Now it becomes magic. We need 3 Steps.

  1. Load data

Just go to the OpenForm Rules and add a new action rule which just load the dataconnection “GetGroupCollectionFromUser”.

  1. Member

Add another action rule to check if the current logged in user is member of the group “Target Group MMC”

First create a condition based on the dataconnection “GetGroupCollectionFromUser” an be sure that you choose “at least one of Name”. Second you have to add an action which sets the value for the boolean field on true. Be sure you marked the selection field for stopping after the condition is true.

  1. Else set false

To be sure that if you are not a member the boolean field is false you have to add another action wich has no condition and just set it to false. This action rule only starts if the condition of rule “member” is not true.

That’s it. Nothing more!

If you are not a member you will get the following result:

If you are a member you will get the following result:

..:: I Like SharePoint ::..

The article or information provided here represents completely my own personal view & thought. It is recommended to test the content or scripts of the site in the lab, before making use in the production environment & use it completely at your own risk. The articles, scripts, suggestions or tricks published on the site are provided AS-IS with no warranties or guarantees and confers no rights.

Dennis de Vries About Dennis de Vries
Loving SharePoint, Social Media and like to work together with creative people all over the world.

3 comments on “How to check if you are a member of a specific group within an InfoPath Form?

  1. Hi,

    I have try this tutorial, but I have a problem by the second point “member”. When I go through the the tree of “GetGroupCollectionFromUser” I have no “folder” with the name “Groups” or “Group”.
    Do you know what this is for a problem?
    I use SharePoint 2010 with Infopath 2010.

    MfG,
    Robert

  2. Can we add/remove users from SharePoint Group using Infopath. If Yes, Please send me the steps or link.

Submit comment

Allowed HTML tags: <a href="http://google.com">google</a> <strong>bold</strong> <em>emphasized</em> <code>code</code> <blockquote>
quote
</blockquote>

Please fill in the captcha: * Time limit is exhausted. Please reload CAPTCHA.