FieldRef element (Query)
Applies to: SharePoint 2016 | SharePoint Foundation 2013 | SharePoint Online | SharePoint Server 2013
Represents a reference to a field within a query.
<FieldRef Alias = "Text" Ascending = "TRUE" | "FALSE" CreateURL = "Text" DisplayName = "Text" Explicit = "TRUE" | "FALSE" Format = "Text" ID = "Text" Key = "Text" List = "Text" LookupId = "TRUE" | "FALSE" Name = "Text" RefType = "Text" ShowField = "Text" TextOnly = "TRUE" | "FALSE" Type = "Text"> </FieldRef>
Elements and attributes
The following sections describe attributes, child elements, and parent elements.
||Optional Boolean. This specifies the sort order on a FieldRef element that is defined in a view. The default value is TRUE.
||Optional Text. Specifies the URL for the .aspx file that is used to create a Meeting Workspace site.
||Optional Text. This attribute provides the display name of the field that is referenced.
||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.
||Optional Text. Specifies the GUID that identifies the field.
||Optional Text. If set to Primary, specifies that the field is the primary key for its table and thus uniquely identifies each record in the table.
||Optional Text. Specifies the parent foreign list when the FieldRef element is a child of an Eq element in Join element. The value is an alias for the list that is defined by the ListAlias attribute of the Join element.
||Optional Boolean. When the field is a Lookup type, specifies that queries should look for the item by its unique item ID rather than the field value. This can be useful, for example, when multiple items have identical values in the field and you want to query for a specific item. The default is false.
||Optional Text. This attribute provides the internal name of the field that is referenced.
||Optional Text. Specifies the type of reference for a field in an events list.
||Optional Text. The ShowField attribute can be set to the field name to display. By default, a hyperlinked text from the Title field of the record in the external list is displayed. But the ShowField attribute can be used to override that and display another field from the external list.
The following data types are allowed as targets of a ShowField attribute: Text, Choice, and Counter.
||Optional Boolean. Specifies that the field contains only text values.
||Optional Text. Specifies the function that is applied to a totals column or a calculated column. Possible values include the following:
AVG Average value. Applies to DateTime Number, Integer, and Currency field types.
COUNT Number of items. Applies to all field types that allow aggregation.
MAX Maximum value. Applies to DateTime Number, Integer, and Currency field types.
MIN Minimum value. Applies to DateTime Number, Integer, and Currency field types.
SUM Sum of values. Applies to Number, Integer, and Currency field types.
STDEV Standard deviation. Applies to Number, Integer, and Currency field types.
VAR Variance. Applies to Number, Integer, and Currency field types.
The values for the Type attribute are not case-sensitive.
- Minimum: 0
- Maximum: 1 (unbounded within OrderBy)
The following example queries for cases where the Expires field is either null or contains a value greater than or equal to the current date.
<Query> <Where> <Or> <IsNull> <FieldRef Name="Expires" /> </IsNull> <Geq> <FieldRef Name="Expires" /> <Value Type="DateTime"> <Today /> </Value> </Geq> </Or> </Where> <OrderBy> <FieldRef Name="Modified" Ascending="FALSE" /> </OrderBy> </Query>
This example from the Schema.xml file for contacts lists fields to display in the toolbar.
<ViewFields> <FieldRef Name="LinkTitleNoMenu"></FieldRef> <FieldRef Name="FirstName"></FieldRef> <FieldRef Name="WorkPhone"></FieldRef> <FieldRef Name="Email"></FieldRef> </ViewFields>