FieldRef Element

The FieldRef element is used in computed fields to refer to the constituent fields and in views to define what fields are present.

Syntax

<FieldRef
  Ascending = "TRUE" | "FALSE"
  Explicit = "TRUE" | "FALSE"
  Name = "Text"
  TextOnly = "TRUE" | "FALSE">
</FieldRef>

Attributes

Name Description
Ascending Optional Boolean. This specifies the sort order on this FieldRef defined in a view. The default value is TRUE.
Explicit Optional Boolean. This attribute is only supported within the ViewFields element. TRUE if the field is explicitly declared in the view definition and is not returned in a Fields enumeration inside a view.
Name Required Text. This attribute provides the internal name of the field that is being referenced.
TextOnly Optional Boolean. Specifies that the field only contains text.
Parent Elements
Eq, FieldRefs, Geq, IsNotNull, IsNull, Neq, OrderBy, ViewFields

Example

The view defined in the following example,

<ows:XML>
  <SetList Name="Announcements"/>
  <View>
    <ViewFields>
      <FieldRef Name="ID" Explicit="TRUE"/>
      <FieldRef Name="LinkTitle"/>
      <FieldRef Name="Body"/>
    </ViewFields>
    <ViewBody><HTML><![CDATA[This is item number]]></HTML><Field Name="ID"/><HTML><![CDATA[<br>]]></HTML>
    <Fields>
      <Property Select="DisplayName"/><HTML><![CDATA[: ]]></HTML><Field/><HTML><![CDATA[<br>]]></HTML>
    </Fields>
  </View>
</ows:XML>

renders the following code for the Announcements page in SharePoint Team Services from Microsoft:

This is item number1<br>Title: <a href="http://server1/Lists/Announcements/DispForm.htm?ID=1" ONCLICK="javascript:DisplayItem('http://server1/Lists/Announcements/DispForm.htm?ID=1', false);javascript:return false;" target="_self">Welcome to your new team web site!</a><br>Body: You can use this site to share information with members of the site. To add a new announcement, click &quot;Add new announcement&quot; above. This is a great way to communicate news with your team.<br>

Note how the view explicitly handles the ID field, and then does a generic rendering of the LinkTitle and Body fields via the Fields enumerator.

The next example presents part of a view definition, specifying LinkTitle, AssignedTo, Status, Priority, DueDate, and PercentComplete fields.

<ViewFields>
  <FieldRef Name="LinkTitle"></FieldRef>
  <FieldRef Name="AssignedTo"></FieldRef>
  <FieldRef Name="Status"></FieldRef>
  <FieldRef Name="Priority"></FieldRef>
  <FieldRef Name="DueDate"></FieldRef>
  <FieldRef Name="PercentComplete"></FieldRef>
</ViewFields>

See Also

DisplayPattern