ViewFields Element (View)

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

<ViewFields>
</ViewFields>
Attributes

Attribute Description

None

N/A

Child Elements

Parent Elements

Occurrences

Minimum: 0

Maximum: 1

Remarks

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.

Example

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

Xml
<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

Other Resources

ViewBidiHeader Element (View)
ViewBody Element (View)
ViewEmpty Element (View)
ViewFooter Element (View)
ViewHeader Element (View)

Tags :


Community Content

rlasker3
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.
Tags :

Page view tracker