4

Is it possible to use two different queries to get to different lists and use them in the same executeQueryAsync()

Something like this :

var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml('<View><Query><Where><Eq><FieldRef Name="IsActive"/><Value Type="Integer">1</Value></Eq></Where><OrderBy><FieldRef Name="SortOrder"/></OrderBy></View></Query>');
this.collListItem = oList.getItems(camlQuery);

var camlQuery1 = new SP.CamlQuery();
camlQuery1.set_viewXml('<View><Query><Where><Eq><FieldRef Name="IsActive"/><Value Type="Integer">1</Value></Eq></Where><OrderBy><FieldRef Name="SortOrder"/></OrderBy></View></Query>');
this.collListItem1 = oList.getItems(camlQuery);


clientContext.load(collListItem,collListItem1);

2 Answers 2

8

Yes you can, but you will have to load the list item collection seperately like below and call executequery once.

clientContext.load(collListItem);
clientContext.load(collListItem1);
0

This is also valid

var allWebs = spCtx.LoadQuery(spCtx.Web.Webs.Include(SharePointWeb.WebInclusions));
var allLists = spCtx.LoadQuery(spCtx.Web.Lists.Include(SharePointList.ListInclusions));
spCtx.ExecuteQuery();

where WebInclusions and ListInclusions are lambda expressions that nominate the fields you want to load.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.