This topic has not yet been rated - Rate this topic

ViewFields Element (View)

Windows SharePoint Services 3

Provides an enumeration of the fields in a view through a listing of the FieldRef elements.


<ViewFields>
</ViewFields>
Attribute Description

None

N/A

Minimum: 0

Maximum: 1

For a FieldRef element to be used within a ViewBody element, it must also be included in the ViewFields element to ensure that the field is available in the database result set.

The SQL SELECT clause is generated from the collection of FieldRef listings.

The following example enumerates the collection of fields used in a view.

<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>
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Limited FieldRef attributes
If you click on the FieldRef link above you will see that it contains many element including the "ID" attribute.

This makes it appear that you can use these attributes like such:

<ViewFields><FieldRef ID='8bea1814-9e9e-4b3e-91c7-cd85817a2b6c'/></ViewFields>

But this does not work. It appears as if only "Name" is allowed. This is a little unusual since you are free to use the ID attribute inside the Where clause.

<Where><Eq><FieldRef ID='8bea1814-9e9e-4b3e-91c7-cd85817a2b6c'/><Value Type='Text'>Sample</Value></Eq></Where>

So, you can filter your result set by the ID of the field but not set which columns are returned. This is disappointing because I am tracking the unique Guids of my Content Type fields but not internal names.