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:
- A group for the red message: NotAGroupMember
- A group for the green message: GroupMember
- 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.
- Load data
Just go to the OpenForm Rules and add a new action rule which just load the dataconnection “GetGroupCollectionFromUser”.
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.
- 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 ::..