GetVar element (View)

Applies to: SharePoint 2016 | SharePoint Foundation 2013 | SharePoint Online | SharePoint Server 2013

Returns a variable in the context of rendering the page. Variables can be set either locally to the current level of XML or globally to the page.

  AutoHyperlink = "TRUE" | "FALSE"
  AutoHyperLinkNoEncoding = "TRUE" | "FALSE"
  AutoNewLine = "TRUE" | "FALSE"
  Default = "TRUE" | "FALSE"
  ExpandXML = "TRUE" | "FALSE"
  HTMLEncode = "TRUE" | "FALSE"
  Name = "Text"
  Scope ="Request"
  StripWS = "TRUE" | "FALSE"
  URLEncode = "TRUE" | "FALSE"
  URLEncodeAsURL = "TRUE" | "FALSE">

Elements and attributes

The following sections describe attributes, child elements, and parent elements.


Attribute Description
AutoHyperlink Optional Boolean. TRUE to surround text with <A> tags if the text appears like a hyperlink, for example,
AutoHyperLinkNoEncoding Optional Boolean. TRUE to surround text with <A> tags if the text appears like a hyperlink (for example, but without HTML encoding.
AutoNewLine Optional Boolean. TRUE to insert <BR> tags into the text stream and to replace multiple spaces with a non-breaking space (&nbsp;).
Default Optional Text. Renders the text assigned to this attribute if the value returned by the Select attribute of another element is an empty string.
ExpandXML Optional Boolean. TRUE to re-pass the rendered content through the Collaborative Application Markup Language (CAML) interpreter, which allows CAML to render CAML.
HTMLEncode Optional Boolean. TRUE to convert embedded characters so that they are displayed as text in the browser. In other words, characters that could be confused with HTML tags are converted to entities.
Name Required Text. The name of the variable.
Scope If set to Request, the variable is globally available on the page.
StripWS Optional Boolean. TRUE to remove white space from the beginning and end of the value returned by the element.
URLEncode Optional Boolean. TRUE to convert special characters, such as spaces, to quoted UTF-8 format, for example, %c3%ab for character ë.
URLEncodeAsUrl Optional Boolean. Like URLEncode, but TRUE to specify that the string to encode is a path component of a URL so that forward slashes (/) are not encoded.

Child elements


Parent elements



  • Minimum: 0
  • Maximum: Unbounded


The GetVar element is often used within an Expr element in a Switch or IfEqual element.

If Scope="Request" is specified in the SetVar element, a variable assignment will take effect anywhere on the current page. Otherwise, the assignment affects only children of the SetVar element.


The following example uses the GetVar element to return current filtering information for determining what text to display in the toolbar above the list.

      <GetVar Name="Filter" />
   <Case Value="1">
      <HTML>Hide Filter Choices</HTML>
            <GetVar Name="FilterField1" />
         <Case Value="">
            <HTML>Change Filter</HTML>

If filter choices are open on the list and the Filter variable contains 1, Hide Filter Choices is displayed. If not, the default action implements a second Switch statement that evaluates a second variable, FilterField1. If the value of FilterField1 is an empty string, no filter is applied and Filter is displayed in the toolbar; otherwise, the default action is to display Change Filter.

See also