Share via


UserID Element

The UserID element can be used to compare the value of a field to the current user.

Syntax

<UserID
  Type = "TRUE">
</UserID>

Attributes

Name Description
Type Optional String. If the Type attribute is present and nonempty, instead of forcing authentication, the element renders an invalid user ID of -1 for anonymous users.
Parent Elements
Default,Expr,Expr2,GetEmailFromUser,Value, Where

Remarks

This element specifies the unique ID number of the currently authenticated user of a subweb as defined in the People (UserInfo) table in the database. If the request is running anonymously, this element by default causes the server to force authentication (in other words, to pop up a password dialog box in the browser or to initiate NTLM challenge/response). If a user has accounts on multiple subwebs or virtual servers, the user ID may be different in each case.

Example

The following query returns cases where either the Author or Editor field is equal to the current value of the UserID element, and it returns the results in ascending order according to the Title field and then the FirstName field.

<Query>
  <Where>
    <Or>
      <Eq>
        <FieldRef Name="Author" />
        <Value Type="Integer">
          <UserID />
        </Value>
      </Eq>
      <Eq>
        <FieldRef Name="Editor" />
        <Value Type="Integer">
          <UserID />
        </Value>
      </Eq>
    </Or>
  </Where>
  <OrderBy>
    <FieldRef Name="Title">
    </FieldRef>
    <FieldRef Name="FirstName">
    </FieldRef>
  </OrderBy>
</Query>