Additional Tips for using the CAML Criteria Builder

Additional Tips for using the CAML Criteria Builder

Return to CAML Criteria Builder or
Select the Filter for your Schema-based Rollup

Some other ways you can use the Criteria Builder to build a CAML Query are outlined below:

You want to… Try this
Use a value that is not listed in the Value column.

If you choose a Person or Group column type and want to use a value that is not listed in the Value list for the column, first select any user and copy the criteria to the CAML Query field. Once the query is in the CAML Query box, manually edit it to replace the selected user between the tags with the unlisted name as it is displayed in SharePoint:

Old CAML: 
  <Value Type="User">Listed User</Value>

New CAML: 
  <Value Type="User">Unlisted User</Value>
Use the SharePoint variable [Me] as the value for a Person or Group column.

This variable is not listed in the Value List by default, but you can still use it. To use the SharePoint variable [Me] as the value for a Person or Group column, first select any user and copy the criteria to the CAML Query field. Once the query is in the CAML Query box, manually edit it to replace the CAML text as shown here:

Old CAML: 
  <Value Type="User">Some User</Value>

New CAML: 
  <Value Type="Integer"><UserID /></Value>

Icon-WarningIMPORTANT 1: The tag <UserID /> is case-sensitive! If you enter <UserId />, you will not get any data.

Icon-WarningIMPORTANT 2: Be careful specifying a filter using [Me] in an alert. That variable designates the logged in user. When the alert is processed, the logged in user is a system account, so an Alert that uses [Me] may not generate any alert messages.

Use the SharePoint variable [Today] as the value for a Date column.

A Date and Time column type automatically displays a Calendar control to select a specific date. To use the [Today] SharePoint variable instead, first select any date and copy the criteria to the CAML Query field. Once the query is in the CAML Query box, manually edit it to change the date value to <Today /> as shown below.

Old CAML: 
  <Value Type="DateTime">2011-05-01T00:00:00Z</Value>

New CAML: 
  <Value Type="DateTime"><Today /></Value>
Add or subtract a number of days from [Today]

To add or subtract a number of days from [Today] to create a filter like “a task overdue by 3 days”, first select any date and copy the criteria to the CAML Query field. Once the query is in the CAML Query box, manually edit it to replace the placeholder date with the following CAML, adjusted for the desired number of days:

Old CAML: 
  <Value Type="DateTime">2011-05-01T00:00:00Z</Value>

New CAML ("3 days after today"): 
  <Value Type="DateTime"><Today /><addValue value="3" /></Value>

New CAML ("3 days before today"): 
  <Value Type="DateTime"><Today /><addValue value="-3" /></Value>