Lately, I have been searching for a solution for one of my InfoPath forms where I need to have different view for the person who fills the form at the first time, and another for the Admin of the form.
The issue is that InfoPath 2007 and 2010 does not support a wizard based functionality to check the current user and it’s groups and comparing them with the SharePoint or AD groups, and User Roles is not supported in InfoPath Form Services.
I have checked many good articles talking about using WSS Web Services to retrieve the User Groups and many other complicated stuff, but I don’t like to comlicate things up.
Well, I have thought in a different direction, where I can create my own simple roles as I will explain here:
1- I have an InfoPath Form published on SharePoint document library, with 2 views, the default and Hidden views.
2- I created a sharepoint List named Admin with one column named UserName, and added the user name accounts for the administrators.
3- You need to create a Data connection to the list, if you don’t know how here is a link to do so:
You just need to read the part of “Add a query data connection”, at the end you will have a data connection to the Admin list.
4- In the InfoPath form, go to Tools — Form Options — choose Open and Save from Category pane.
5- Click on Rules button, and the Add button to add new rule.
6- Click on Set Condition button on Rule diagram.
7- Then from the drop down menu chose “Select a field or group“.
8- Then Select a Field or Group dialog window will open, chose the Data source for the Admin List, then chose the column name (UserName), and from the Select dropdown chose “Any occurrences of UserName“, then Click OK button.
9- Then, chose “is equal to” , and chose “Use a formula“, a chose the formula “userName()“.
10- Then click on OK button, and now we need to add an action to swith the view named “Hidden” as per the following illustration.
Now, whenever a user from the Admin list open the Form, it will switch to the view named Hidden.