Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SharePoint : How to check for null with a CAML Query?

Tags:

sharepoint

I have this CAML:

query.Query = @"<Where><Eq><FieldRef Name='MessageID' /><Value Type='Text'></Value></Eq></Where>"; 

This checks if the value of MessageID = string.empty()

What I would like to check for is null.... not empty string...

Is this possible with CAML?

like image 432
JL. Avatar asked Aug 27 '09 13:08

JL.


People also ask

What is CAML Query in SharePoint?

CAML is an XML-based language that is used in Microsoft SharePoint Foundation to define the fields and views that are used in sites and lists.

Is CAML Query case sensitive?

There is no option for case sensitivity in caml queries.


2 Answers

CAML has the IsNull operator,so the query would be:

query.Query = @"<Where><IsNull><FieldRef Name='MessageID' /></IsNull></Where>" 
like image 144
Colin Avatar answered Sep 19 '22 00:09

Colin


Needed an equivalent to String.IsNullOrEmpty(Description). Ended up with this:

<And>   <IsNotNull>       <FieldRef Name='Description' />      </IsNotNull>     <Neq>       <FieldRef Name='Description' />       <Value Type='Text'></Value>     </Neq> </And> 
like image 38
Stephane Avatar answered Sep 18 '22 00:09

Stephane