I am trying to use the javascript object model to retrieve multiple lists from the current web.
I am able to get them all and then filter out through an if
condition, but ideally I would like to build up a query so I can only get the lists I want right out of the returned query (like Linq
in C#
or CAML
in GetListItems
).
var context = new SP.ClientContext.get_current();
var web = context.get_web();
var lists = web.get_lists();
context.load(lists, 'Include(RootFolder, Title, BaseTemplate, Hidden)');
context.executeQueryAsync(
...
if(list.get_baseTemplate() === 101)
{
//do stuff
}
)
So is there any way I can do something like this in javascript?
context.loadQuery(lists.Where(l => l.BaseTemplate == 101));
I've found an example using REST
, I'm just not sure it this makes sense as I was hoping to stick with csom. Anyway, I'd like to hear some thoughts on how to best tackle this, as I'm sure retrieving all lists will bring an additional unecessary overhead.