0

Hi I'm in need of some help with a caml query. I have 1 column in my list, that have 3 different choice.

I want to query out items if the choice is equal to YES

This is my code:

var context = new SP.ClientContext.get_current();
enter code hered

var web = context.get_web(); 
var list = web.get_lists().getByTitle("MyList");  

var viewXml = String.format(
"<View>" +
"<Query>" +
"<Where>" +
"<Eq>" +
"<FieldRef Name='MyChoiceField' />" +
"<Value Type='Choice'>YES</Value>" +
"</Eq>" +
"</Where>" +
"</Query>" +
"</View>");

var query = new SP.CamlQuery();
query.set_viewXml(viewXml);
this.items = list.getItems(query);

The rest of the code works except the query

4
  • Is it a typo, there is no + after "</Where>" Feb 28, 2014 at 14:55
  • In my environment there is a +, i missed it here
    – Anders
    Feb 28, 2014 at 14:58
  • what is the actual name of the field. Perhaps you may not be using the internal name of the field. Feb 28, 2014 at 15:03
  • Updated it as the answer so that it can be closed. Feb 28, 2014 at 15:54

1 Answer 1

2

Check the internal name of the field. The CAML query needs the internal name of the field.

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.