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.

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

3 Comments

  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

Leave a Reply

Your email address will not be published.


*