How to use query functions

Document created by Iryna Employee on Feb 13, 2018
Version 1Show Document
  • View in full screen mode

Context placeholder functions allow querying lists so that values from any list can be used in expressions. I.e. [[@Web.GetFirstValueForQuery('ListName, list Id or Relative URL', 'Caml query', 'FieldName')]].



The first parameter can be set as:
  • List Name (usual name, not internal one): for lists from the current site.

I.e. [[@Web.GetFirstValueForQuery('Contacts', '<Where><BeginsWith><FieldRef Name="Title"/><Value Type="Text">Contoso</Value></BeginsWith></Where>', 'Title')]]) 


  • List Id (Guid): for lists from the current site.

I.e.  [[@Web.QueryList ('198BBEA5-3C38-4A00-861E-0A8873905924', '<Where><BeginsWith><FieldRef Name="Title"/><Value Type="Text">[[Title]]</Value></BeginsWith></Where>' , 1, 'ID', '')]][0]["ID"]


  • Relative URL of the list: for any list from the current site collection.

I.e. [[@Site.GetFirstValueForQuery('/sites/Contoso/Clients/Lists/Contacts', '<Where><BeginsWith><FieldRef Name="Title"/><Value Type="Text"> [[{ return [[Title]]; }]] </Value></BeginsWith></Where>', 'Title')]]

Note: Current version doesn't support cross-site collection relative URLs.


2 people found this helpful