1

I have the following CAML query

CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<Query><Where><Eq><FieldRef Name='RiskRequestID'/><Value Type='Text'>" + r.id + "</Value></Eq></Where></Query>";
ListItemCollection oListItems = context.Site.RootWeb.GetList(UFSsiteUrl + "Lists/RiskManagement/").GetItems(camlQuery);
context.Load(oListItems);
context.ExecuteQuery();

to get the item with the entered RiskRequestID.. currently instead of getting one item i am getting all the items inside the list.. any advice?

and the RiskRequestID is a SharePoint field of type Single Line of text.

1 Answer 1

1

camlQuery.ViewXml needs to contain a query wrapped in a <View> node:

CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = "<View><Query><Where><Eq><FieldRef Name='RiskRequestID'/><Value Type='Text'>" + r.id + "</Value></Eq></Where></Query><View>"; 

When you don't include <View>, the query is considered malformed and as a result, it returns all items.

Your Answer

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

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