Granular Permissions With InfoPath 2007 Forms
Consider a scenario where an insurance form is built using InfoPath 2007 which includes some approval process too. In the approval process, some information in the form should only be shared to the approvers group (like approvers comment) and not to the normal users.
It would be preferred to put all approvers into a single group, so that relative group information(like approvers comment) could be shown to particular group (only Approvers Group). To display group related information inside the form, we need to have basic group information like "GroupName". To fetch group information of a particular logged in user, we could use UserGroup web service which will provide group information like GroupId, GroupName and others.
The problem with this approach is that by default, the UserGroup web service doesn't provide this information. The template only provides information about a particular user like UserLoginName and nothing about its group.
The solution is to fetch desired information like GroupId, GroupName and others using the UserGroup web service. We also need to modify the template in a way it would provide other information too.
First, we create a data connection using UserGroup.asmx to receive data and use the GetCollectionfromUser method to fetch group details of a particular user. After a successful creation, it would be something similar to the image show below:
Now as shown in above image, GetGroupCollectionFromUser provides only a single piece of information i.e. userLoginName. But in order to get group information, you need to change the schema definition of GetGroupCollectionFromUser, so that you could receive other details too.
Click on File > Save as Source Files
I prefer to save the files in a new folder at the same location where your form exists on file system. After saving, close the form and go to the folder that contains your saved source files. There would be multiple GetGroupCollectionFromUser.xsd files like GetGroupCollectionFromUser1.xsd, GetGroupCollectionFromUser2.xsd, etc. Now be careful in selecting the correct file. To trace the correct file, open the file which is highest in size among all GetGroupCollectionFromUser.xsds like shown below.
Further, we need to define a custom template which will replace the default template of GetGroupCollectionFromUser in GetGroupCollectionFromUser1.xsd in my case.
Open this link and paste the code as follows:
Now search for GetGroupCollectionFromUser and you will find a template like below mentioned:
Replace the above template with below one:
Save the file and close.
Now go back to the folder of source files and press right click on manifest.xsf
Now you could see the additional group information in the form that we changed in the schema definition file, which will allow you to access group information.
Save it as new form and you will be able to access all information.
- Use the same steps for targetting any particular group for particular process inside InfoPath 2007
- Use this approach instead of code behind in InfoPath 2007 as it is considered more robust and less complexed compared to code behind.
- Check out MSSQLTips.com for great information about Microsoft SQL Server.
About the author
View all my tips