Applies To:

SharePoint/InfoPath List Forms


Sometimes we need to restrict sections in forms to a certain group of users. Instead of simply marking them with a heading such as "HR Use Only" or "Information Services Use Only", we can show or hide a section based on the logged in user. This article describes how to achieve that in InfoPath.

​Creating the Lists

In order to restrict sections in a form, we will need to create a list that contains the users who will have access to the section. We will reference this list in a data connection in InfoPath.

Create the User List

  1. Create a custom list and name it ElevatedPermissionsUsers
  2. Create a new column:
    1. Column name: AdminUser
    2. Type: Person or Group
    3. Required: Yes
    4. Allow selection of: People Only
    5. Accept the defaults for everything else
  3. In Advanced Settings, Allow management of content types
  4. Change the Item content type and hide the Title field
  5. Change the default All Items view:
    1. Remove the Title field
    2. Add Edit (link to edit item) and move it to the first column

Now that your list is ready, add a couple of site users to the list.

Customizing the 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.

For this excersize, I've created a custom list and named it RestrictedInfoPathSections.

Create the List

  1. Accept the default Title field
  2. Create the following fields. For simplicity I kept them as single lines of text except the IsAdmin field, however they can be any field type

     Name Type
     FirstName Single line of text
     LastName Single line of text
     Manager Single line of text
     EmployeeAction Single line of text
     CurrentUser  Single line of text (Hide in all views)
     IsAdmin Number (Hide in all views)

Customize the list in InfoPath

  1. On the list ribbon, click the Customize in InfoPath button
  2. On the newly created InfoPath form
  3. Delete the last four rows including the fields, Manager, CurrentUsaer, IsAdmin and EmployeeAction
  4. Add a new section to the bottom of the form
  5. Insert a Two-Column with Emphasis 3 table layout in the new section
  6. Add the Manager and EmployeeAction fields in the new table
  7. Format and change themes to your liking

Manage the Data Connections

  1. Add a new connection to the ElevatedPermissionsUsers list and name it GET-ElevatedPermissionsUsers
  2. Select the following fields:
    1. AdminUser
    2. ID

  3. Accept the defaults and complete the wizard steps

Create the Rules

  1. Select the DATA tab in the ribbon
  2. In the Rules section, click on the Form Load button
  3. Create a new Action rule and name it Assign Admin Users
  4. Accept the default Condition - None - Rule runs when form is opened
  5. Create a new Set a field's value action:
    1. Field: IsAdmin
    2. For Value, click on the fx button
    3. Click Insert a Field or Group
    4. Click on Show advanced view
    5. Change the data source to GET-ElevatedPermissionsUsers
    6. Under dataFields, drill down and select ID

    7. Click Filter Data
    8. Click Add
    9. In the first drop-down box change ID and click Select a field or group...
    10. On the Data source dialog, under dataFields, drill down and select AdminUser AccountID

    11. Click OK
    12. Accept the default in the second drop-down: is equal to
    13. From the third drop-down, select Use a fornula...
    14. On the Insert Formula dialog, click the middle button Insert Function...
    15. Select the userName function and click OK

    16. Click OK several times to close all dialog boxes
    17. The final Rule Details dialog should look similar to the image below:

    18. Click on the section tab that contains your restricted content
    19. Create a new formatting rule and name it Hide From Non-Admin Users
    20. Set the condition to IsAdmin = Is blank
    21. Select the Hide this control check-box

    22. Right-click on the CurrentUser field in the fields section and select Field Properties...
    23. Change the Default Value by clicking the fx button next to the Value text box
    24. Insert the userName function

    25. 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.