Introduction
During a recent client build (JPMC), I had a custom SharePoint list InfoPath requirement where I had to restrict a section of the InfoPath form view (I created 4 in total…see more here) to a specific group of users (‘Management Use’ only). Instead of simply marking the section/fields with a heading such as ‘Management Use only’, I can show or hide this section based on the logged in user and separate custom permissions list where we can maintain the specific management group. This ariticle describes how to achieve that in InfoPath.
Table of Contents
Creating the ‘Management’ List
In order to restrict sections in the form, create a custom list that contains the users who will have access to the section. We will reference this list in a data connection in InfoPath.
- Create a custom list and name it: ElevatePermissionsUsers
- Create a new column:
- Column name: Admin/User
- Type: Person or Group
- Required: Yes
- Allow selection of: People Only
- Accept the defaults for everything else
- In Advanced Settings, Allow management of content types
- Change the Item content type and hide the Title field
- Change the default All Items view:
- Remove the Title field
- Add Edit (link to edit item) and move it to the first column
Now your list is ready, Add a couple of site users to the list.
Customizing the InfoPath List Form
If you don’t already have a list form that you need to customize, create one now. It can be based on a Custom list template, or any other list template that you need, such as Tasks.
Add linkage fields
For this customer, I created a custom list and named it IOLRequest. By adding two additional fields, IsAdmin (number, hide in all views) and CurrentUser (single line of text, hide in all views) to IOLRequest, I created a relational interchange between IOLRequest and the previously created ElevatePermissionsUsers.
Now let’s return to the InfoPath List Form by clicking the Customize in InfoPath button from any IOLRequest list view. Click on the DATA tab on the InfoPath Ribbon, then go to Manage Data Connections.
Manage Data Connections
Add a New connection to ElevatePermissionsUsers list and name it GET-ElevatePermissionsUsers.
Select the following fields:
AdminUser
ID
Accept the defaults and complete the wizard steps
Create the Rules
- Select the DATA tab in the ribbon
- In the Rules section, click on the Form Load button
- Create a new Action rule and name it Assign Admin Users
- Accept the default Condition – None – Rule runs when form is opened
Manage Restricted Section
1. Click on the section tab that contains your restricted content
2. Create a new formatting rule and name it Hide From Non-Admin Users
3. Set the condition to IsAdmin = Is blank
4. Select the Hide this control check-box
5. Right-click on the CurrentUser field in the fields section and select Field Properties…
6. Change the Default Value by clicking the fx button next to the Value text box
7. Insert the userName function
Publish the form
Test the form by signing in to the site with a user who is in the ElevatedPermissionsUsers list, then with one who’s not in this list.