0

I have the following CAML query inside our SharePoint online site collection, to get all the list items which have a choice field named CustomerOrderAlert = No, as follow:-

                List customerliveorderlist = omsWeb.GetList(web.ServerRelativeUrl + "/lists/CustomerLiveOrder/");
                CamlQuery query1 = new CamlQuery();
                query1.ViewXml = @"<Where><Eq><FieldRef Name ='CustomerOrderAlert'/><Value Type='Choice'>No</Value></Eq></Where>";
                ListItemCollection c = customerliveorderlist.GetItems(query1);

                     context.Load(c,
                           items => items.Include(
                           item => item["OrderLiveDeliveredDate"],
                           item => item.Id,
                ));
                context.ExecuteQuery();

but i am getting all the items even the ones which have their CustomerOrderAlert = Yes? any idea? Thanks

1 Answer 1

3

You need to add View and Query element to your query. Try below

query1.ViewXml = @"<View><Query><Where><Eq><FieldRef Name ='CustomerOrderAlert'/><Value Type='Choice'>No</Value></Eq></Where></Query></View>";
1
  • worked well thanks
    – John John
    Commented May 15, 2020 at 21:28

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.