Add a user role

When you design a form template, you can specify user roles. User roles are predefined categories that can be assigned to form users based on their job title or some other criteria. User roles can be used to present customized views of a form to different types of users, display different sections in a view, or calculate the default value of a field or control. For example, if you are designing a permit application form template, you can create different views of that form template for contractors, receiving agents, and administrators and then assign each user role to a separate view. When users open a form that is based on your form template, Microsoft Office InfoPath determines the user role based on the user's name, and then opens the appropriate view based on that user role.

Security Note: User roles should not be used to restrict access to sensitive data in a form. Even if you make a form template read-only or hide certain controls that are based on user roles, users can potentially use a text-editing program such as Microsoft Notepad to view or modify the form template (.xsn) file and access that data.

In this article

Overview

Compatibility considerations

Before you begin

Add a user role

Display a view that is based on a user role

Test the user roles

Overview

When you create a new user role, you can assign users to it in the following ways:

  • By specifying user names from a Microsoft Active Directory directory service (for example, "sales\andrew"). To specify a user name in an Active Directory directory service, the form template must be created in and published to a Microsoft Windows network that uses Active Directory.

  • By specifying groups from an Active Directory directory service. For example, you can specify an e-mail distribution list that contains the names of all of the members of the marketing team. To specify a group in an Active Directory directory service, the form template must be created in and published to a Microsoft Windows network that uses Active Directory.

  • By specifying a value that comes directly from a field in the form. The field may get data from Active Directory, or the user can enter data into a control that is bound to this field. For example, if your form template contains an Administrator text box, you can associate a particular user role with the field to which that text box is bound.

After you add a user role, you can set it as one of the following:

Default role    Users who are not assigned to an existing user role are automatically assigned to the user role that is specified as the default role. The default role is also used for users who are part of a group but who are working offline. One user role is always set as the default.

Initiator role    If you want to apply a particular user role to users who open your form for the first time, you can specify an initiator role. For example, you can define an initiator role named "Contractor" that applies to users who fill out new permit application forms. A user who is assigned to a different user role is automatically reassigned to the contractor role when he or she opens a new permit application form. However, the next time that user opens the same form, Microsoft Office InfoPath uses the person's assigned user role instead of the initiator role.

If you have assigned roles to users that are based on any combination of user names, groups, or values from a field, when a user opens a form that is based on your form template, InfoPath determines the role to assign to that user by using the following order:

  1. The user's name is a value of a field in the form template.

  2. The user's name is in Active Directory.

  3. The user is a member of an Active Directory group.

    Note: If the user is a member of several groups and you are assigning user roles that are based on a group, InfoPath checks the member list of each group in the order that the group is listed in the Manage User Roles dialog box. For example, if the user is a member of both the receiving agent group and the administrator group, and the administrator group is listed before the receiving agent group, the user will be assigned the user role for the administrator group.

  4. If none of the above are true, the default role is used.

After you define the user roles for your form template, you can set up a rule that automatically switches views on the basis of the user's role. For example, you can create a manager user role and then create a rule to automatically switch to the manager view when a user who is assigned to the manager role opens the form. Alternatively, you can create the rule first and then define the user roles as part of the process of creating the rule.

Top of Page

Compatibility considerations

You cannot create user roles in a browser-compatible form template. You create user roles only in a form template whose forms will be filled out in InfoPath.

Top of Page

Before you begin

Before you can add user roles to your form template, you need the following:

  • A list of the user roles that you want to add, along with the members of each user role. The members can be user names or groups from a Microsoft Active Directory directory service or a value entered by a user in a control that is bound to a specific field in the form template's data source.

  • The default user role that you want to assign to users who open a form that is based on your form template, when they are not a member of any user role.

Top of Page

Add a user role

  1. On the Tools menu, click User Roles.

  2. In the Manage User Roles dialog box, click Add.

  3. In the Role name box, type a name for the new user role.

  4. To assign users or groups of users to the role, do one or more of the following.

    Specify one or more users who are part of a network that uses the Active Directory directory service

    1. Select the User names check box, and then click Select one or more users Button image .

      Note: If you already know the domain and user name, type them in the User names box. They must be in the format domain\user name. Separate multiple user names with semicolons (;).

    2. In the Enter the object names to select box, type one or more user names, separated by semicolons (;).

      Note: For information about how to format the user names, click the examples link in the dialog box.

    3. To check the user names that you typed against the names in Active Directory, click Check Names.

    4. Click OK.

    Specify one or more groups that are part of a network that uses the Active Directory directory service

    1. Select the Group names check box, and then click Select one or more groups Button image .

      Note: If you already know the group name, type it in the Group names box. It must be in the format domain\user name. Separate multiple group names with semicolons (;).

    2. In the Enter the object names to select box, type one or more group names, separated by semicolons (;).

      Note: For more information about how to format the group names, click the examples link in the dialog box.

    3. To check the group names that you typed against the names in Active Directory, click Check Names.

    4. Click OK.

    Specify user names that come directly from a field in the form

    1. Select the User names from the form check box, and then click Select a field in the data source Data Source button .

    2. In the Select a Field or Group dialog box, click the field that will provide the values that you want for the user roles, and then click OK.

  5. To set the user role as the initiator role, select the Set as initiator check box, and then click OK.

    Note: When a user role is specified as the initiator, this role takes precedence over all other role assignments even if the initiator role is in the middle of the list in the Manage User Roles dialog box.

  6. To specify a default user role for users who are not members of any other roles, select the role in the Manage User Roles dialog box, and then click Set as Default.

    Note: You must have more than one user role in order to click Set as Default.

Top of Page

Display a view that is based on a user role

If you are designing a form template that includes user roles and contains multiple views, it can be useful to display a view that is based on the user role that is assigned to a user. For example, you can use a rule to have a specific view open when a user who is assigned to a specific user role opens a form that is based on your form template.

  1. On the Tools menu, click Form Options.

  2. In the Category list in the Form Options dialog box, click Open and Save.

  3. Under Open behavior, click Rules.

  4. Click Add.

  5. In the Name box, type a name for the rule.

  6. Click Set Condition.

  7. In the first box, click User's current role.

  8. In the second box, click is equal to.

  9. In the third box, click the name of the user role, and then click OK.

  10. In the Rule dialog box, click Add Action.

  11. In the Action list, click Switch views, and then click a view in the View list.

Top of Page

Test the user roles

If a form has multiple user roles, it is a good idea to test the appearance and behavior of each distinct role. Although you can preview a form template to check whether the views work as you expect with user roles, you will not be able to simulate the process of evaluating a user against the user's given role assignment. That is because InfoPath checks the user roles when you fill out the form, not when you preview it. If you want to fully test the user roles for your form template, you can temporarily assign yourself to each user role that you want to test and then open the form as if you are going to fill it out.

  1. On the Tools menu, click Form Options.

  2. Click Preview in the Category list.

  3. In the Preview as list under User role, click the role that you want to preview, and then click OK.

  4. To test your changes, click Preview on the Standard toolbar, or press CTRL+SHIFT+B.

    The name of the current user role appears on the status bar in the lower-right corner of the preview window.

Top of Page

Share Facebook Facebook Twitter Twitter Email Email

Was this information helpful?

Great! Any other feedback?

How can we improve it?

Thank you for your feedback!

×