I have to send more than one ID to CAML query. But got struck with the or condition. How can we implement or
condition for unknown number of ID's to be passed to the query. I have done in for two ID's, now I need to do it for unknown number of ID's to be passed.
$('#tblCustomListData tbody').empty();
var array = $('#userid').val().split(",");
var camlQuery ="<Or>";
$.each(array,function(i){
array[i] = array[i].trim();
camlQuery = camlQuery + "<Eq><FieldRef Name='ID' /><Value Type='Text'>" + array[i] + "</Value></Eq>";
});
camlQuery2 = camlQuery + "</Or>";
camlQuery2 = "<View Scope='RecursiveAll'><Query><Where>"+ camlQuery2 +"</Where></Query></View>";
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var list = web.get_lists().getByTitle('DocumentList');
var fileName = document.getElementsByName('userid')[0].value;
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(camlQuery2);
allItems = list.getItems(camlQuery);
context.load(allItems, 'Include(Title,DocumentTitle,Description0,DocID,OHRID,Modified,FileRef)');
How do we implement a query so that it work for any number of ID's.