I'm using SharePoint 2013 and want to use CSOM/CAMLquery to retrieve some related information in another list. The related list may have 500+ items in it and I want to return information about maybe 20 of them. The only information I have about the 20 items is their ListItemID which is stored as the "look up key" in the related list.

I've found all kinds of tutorials for looking up the items one at a time.

var ItemContext = new SP.ClientContext(<siteURL>);
var relatedList = ItemContext.get_web().get_lists().getByTitle(<listname>);
var camlQuery = new SP.CamlQuery();

camlQuery.set_viewXml("<View>" +
                        "<Query>" +
                         "<Where><Eq>" +
                            "<FieldRef Name=\'RelatedItemID\'/>" +
                             "<Value Type=\'Number\'>"+ListItemID+"</Value>" +
                         "</Eq></Where>" +
                        "</Query>" +
var collListItem = relatedList.getItems(camlQuery); 
ItemContext.load(collListItem, 'Include(ID,OtherProperties....)');

And that seems to work well. But I have to make a call for each of the 50 items.

Is there a way I can query for all 50 items at once? I'm not having much luck search for that. Most tutorials show how to filter on some common value in the part, but not how to query on 50 different values.

1 Answer 1


You should try the IN operator in caml query

<Where> <In> <FieldRef Name="RelatedItemID" /> <Values> <Value Type="Number">1</Value> <Value Type="Number">2</Value> ... </Values> </In> </Where>

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.