0

I am trying to write a CAML Query that returns all items from the list where in the "Title" field they contain "No Title". (In order to delete them later).

The deletion is done in Csharp.

I have come up with the below query:

<View><Query><Where><Contains><FieldRef Name='Title' /><Value Type='Text'>No Title</Value></Contains></Where></Query></View>

It there is one item containing "No Title" it works, returns one item. If there is several items containing "No Title", it only returns one item as long as the fields have the same string.

Is there anything missing to my query?

  • Make sure you are writing the query under double quotes as: camlQuery.ViewXml = "<View><Query><Where><FieldRef Name='Title' /><Value Type='Text'>No Title</Value></Eq></Where></Query></View>"; – Sohail Shaikh Oct 15 '18 at 9:28
  • @SohailShaikh Yes it has double quotes. – Robert Mazurowski Oct 15 '18 at 10:41
  • 2
    Are you certain that the items actually have the "No Title" value? AFAIK this is the display text generated by the "LinkTitle" field (when displayed in the UI) that displays this a fallback text. If the "Title" field is actually empty, you should use "<IsNull><FieldRef Name='Title' /></IsNull>" to locate the items in question. – J. Tihon Oct 15 '18 at 10:58
0

The CAML looks ok. Maybe it is your C# code that is causing the trouble. Have a look at the sample code here.

0

Try using following code in your query:

"<Where><IsNull><FieldRef Name='Title' /></IsNull></Where>"

Please upvote if this answer helped you in any way.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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