# roles Element

Defines roles.

## Type

`xsd:complexType`

## Child Elements

Element | Description
--- | ---
role | Defines role.
membership | Maps a user or group of users to a role.

## Attributes

Attribute | Type | Required | Description | Possible Values
--- | --- | --- | --- | ---
default | `xsd:string` | Yes | Specifies the name identifier of the role that is the default role. | string
initiator | `xsd:string` | No | Specifies the name identifier of the role chosen to be the initiator role. | string
hideStatusBarDisplay | `xdYesNo` | No | Specifies whether the current role should be displayed in the status bar. | yes no

## Definition

    <xsd:element name="roles">
      <xsd:complexType>
        <xsd:sequence>
          <xsd:element ref="xsf:role" minOccurs="1" maxOccurs="unbounded"/>
          <xsd:element ref="xsf:membership" minOccurs="0" maxOccurs="1"/>
        </xsd:sequence>
        <xsd:attribute name="default" type="xsd:string" use="required"></xsd:attribute>
        <xsd:attribute name="initiator" type="xsd:string" use="optional"></xsd:attribute>
        <xsd:attribute name="hideStatusBarDisplay" type="xsf:xdYesNo" use="optional"></xsd:attribute>
      </xsd:complexType>
      <!-- role names must be unique -->
      <xsd:unique name="roles_name_unique">
        <xsd:selector xpath="./xsf:role" />
        <xsd:field xpath="@name" />
      </xsd:unique>
      <!-- fields must reference existing role -->
      <xsd:key name="role_name_key">
        <xsd:selector xpath="./xsf:role" />
        <xsd:field xpath="@name" />
      </xsd:key>
      <xsd:keyref name="role_default" refer="xsf:role_name_key">
        <xsd:selector xpath="." />
        <xsd:field xpath="@default" />
      </xsd:keyref>
      <xsd:keyref name="role_initiator" refer="xsf:role_name_key">
        <xsd:selector xpath="." />
        <xsd:field xpath="@initiator" />
      </xsd:keyref>
      <xsd:keyref name="role_membership" refer="xsf:role_name_key">
        <xsd:selector xpath="./xsf:membership/*" />
        <xsd:field xpath="@memberOf" />
      </xsd:keyref>
    </xsd:element>

## Remarks

Note This item is not supported when the Disable Service Pack features option on the Advanced tab of the Options dialog box in InfoPath is selected or when Microsoft Office 2003 Editions Service Pack 1 or later is not installed. Any form defined by a form definition file (.xsf) that includes this item cannot be opened in InfoPath when service pack features are disabled or unavailable.

## Example

The following is an example of the roles element:

    <xsf:roles initiator="A" default="C" hideStatusBarDisplay="yes">
       <xsf:role name="A"/>
       <xsf:role name="B"/>
       <xsf:role name="C"/>

       <xsf:membership>
          <xsf:getUserNameFromData dataObject="catalog" select="/dfs:myFields/dfs:dataFields/d:UserA" memberOf="B"/>
          <xsf:userName name="Domain\username1" memberOf="A" />
          <xsf:userName name="Domain\username2" memberOf="B" />
          <xsf:group name="Domain\username3" memberOf="C" />
       </xsf:membership>
    </xsf:roles>

©2003-2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp