I have a list inside SharePoint online site collection. the list contain a field named Processed which is of type single line of text, and only one item have a value inside this field while the other does not have values.

I write this CAL query to get the single item:

List oList = context.Site.RootWeb.Lists.GetByTitle(listname);
                CamlQuery camlQuery2 = new CamlQuery();
                camlQuery2.ViewXml = "<Query><Where><Contain><FieldRef Name='Processed'/>" +
                    "<Value Type='String'>Not Processed</Value></Contain></Where></Query>";

                ListItemCollection collListItem2 = oList.GetItems(camlQuery2);
                foreach (ListItem li in collListItem2)

but this CAML returned all the items, although one item has the correct value, while the other have empty/null value for the Processed field.

Any advice to resolve this issue?

1 Answer 1


Try using below query in ViewXml (Use internal name of Processed field):

                <FieldRef Name='Processed'/><Value Type='Text'>Not Processed</Value>

You can also add below to set the row limit to 1:


official documentations:

  1. How to: Retrieve List Items.
  2. Query schema.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.