CAML: Select SharePoint List Items with not empty column values




Once I needed a CAML query for selecting elements with non-empty column. I wanted to select all the users with name detected (filled) and with OS "Windows".

First I decided to use <Neq> construction and <Value Type='Text'></Value>. I thought it’s an analog for var != "". But the result was wrong.

 

So I watched CAML documentation and found <IsNotNull> construction. It appeared to be right:

 

This query returns list items where "OS" is "Windows" and UserName not null.

If you need to select elements with Null-values, you should use <IsNull> construction.

 



MarkiMarta.com. Notes of web-specialist
Since 2009
18+
Get available SharePoint list field options in a field type (Multi)Choice from codebehind

In a list with a field type “Choice” you can know available options of this field from codebehind without reading...

Close