I have an SP list of items, each item has a unique Title. I would like to use the title as my way to find and then update that row of data. I thought the below code would find only the item that has a Title = "Apptest" but it always gives me all items in the list and all of them are updated. I get the same results if I remove the ViewXml line, so I think there is something wrong with that line but I can't find it. Before: Before running code After:After running the code

var list = clientContext.Web.Lists.GetByTitle("Test");
            var camlQuery = new CamlQuery
                ViewXml = @"<Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>Apptest</Value></Eq></Where></Query>"

            var listItems = list.GetItems(camlQuery);

            foreach (var listItem in listItems)
                listItem["Title"] = "AppUpdateTest";

1 Answer 1


Please have a try to add 'View' around 'Query' like below:

{ ViewXml = "<View><Query><Where><Eq><FieldRef Name='Title' /><Value Type='Text'>xxxxx</Value></Eq></Where></Query></View>"};

Reference docs:

  • Thanks! I figured it would be something simple. Jun 1, 2020 at 11:46

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.