Search This Blog

Saturday, July 29, 2017

Batch Execution Jsom (Get record of multiple list in Single Query execution)

<asp:Content ContentPlaceHolderId="PlaceHolderMain" runat="server">
                <div class="ms-hide">
                <WebPartPages:WebPartZone runat="server" title="loc:TitleBar" id="TitleBar" AllowLayoutChange="false" AllowPersonalization="false" Style="display:none;"><ZoneTemplate>
                <WebPartPages:TitleBarWebPart runat="server" HeaderTitle="batchJSOM" Title="Web Part Page Title Bar" FrameType="None" SuppressWebPartChrome="False" Description="" IsIncluded="True" ZoneID="TitleBar" PartOrder="2" FrameState="Normal" AllowRemove="False" AllowZoneChange="True" AllowMinimize="False" AllowConnect="True" AllowEdit="True" AllowHide="True" IsVisible="True" DetailLink="" HelpLink="" HelpMode="Modeless" Dir="Default" PartImageSmall="" MissingAssembly="Cannot import this Web Part." PartImageLarge="" IsIncludedFilter="" ExportControlledProperties="True" ConnectionID="00000000-0000-0000-0000-000000000000" ID="g_2122924d_336f_4255_84f3_f0b1a2263a0b" AllowClose="False" ChromeType="None" ExportMode="All" __MarkupType="vsattributemarkup" __WebPartId="{2122924D-336F-4255-84F3-F0B1A2263A0B}" WebPart="true" Height="" Width=""></WebPartPages:TitleBarWebPart>

                </ZoneTemplate></WebPartPages:WebPartZone>
  </div>
  <table class="ms-core-tableNoSpace ms-webpartPage-root" width="100%">
                                                                <tr>
                                                                                <td id="_invisibleIfEmpty" name="_invisibleIfEmpty" valign="top" width="100%">
                                                                                <WebPartPages:WebPartZone runat="server" Title="loc:FullPage" ID="FullPage" FrameType="TitleBarOnly"><ZoneTemplate></ZoneTemplate></WebPartPages:WebPartZone> </td>
                                                                </tr>
                                                                <SharePoint:ScriptBlock runat="server">
                                                                if(typeof(MSOLayout_MakeInvisibleIfEmpty) == &quot;function&quot;)
                                                               
                                                                {MSOLayout_MakeInvisibleIfEmpty();}</SharePoint:ScriptBlock>
                                </table>
                                <script type="text/javascript">
var clientContext = null;
var web = null;
ExecuteOrDelayUntilScriptLoaded(Initialize, "sp.js");
function Initialize()
{
clientContext = new SP.ClientContext.get_current();
web = clientContext.get_web();


var list = web.get_lists().getByTitle("LyteBox Photos");
var camlQuery = new SP.CamlQuery();
var q = '<View/>';
camlQuery.set_viewXml(q);
this.listItems = list.getItems(camlQuery);
clientContext.load(listItems, 'Include(DisplayName,Id)');


var list = web.get_lists().getByTitle("Awards");
var camlQuery = new SP.CamlQuery();
var q = '<View/>';
camlQuery.set_viewXml(q);
this.listItems1 = list.getItems(camlQuery);
clientContext.load(listItems1, 'Include(DisplayName,Id)');


var list = web.get_lists().getByTitle("LyteBox Photos");
var camlQuery = new SP.CamlQuery();
var q = '<View/>';
camlQuery.set_viewXml(q);
this.listItems2 = list.getItems(camlQuery);
clientContext.load(listItems2, 'Include(DisplayName,Id)');


var list = web.get_lists().getByTitle("LyteBox Photos");
var camlQuery = new SP.CamlQuery();
var q = '<View/>';
camlQuery.set_viewXml(q);
this.listItems3 = list.getItems(camlQuery);
clientContext.load(listItems3, 'Include(DisplayName,Id)');


clientContext.executeQueryAsync(Function.createDelegate(this, this.onListItemsLoadSuccess),
Function.createDelegate(this, this.onQueryFailed));
}
function onListItemsLoadSuccess(sender, args) {
                var listEnumerator = this.listItems.getEnumerator();
                var listEnumerator1 = this.listItems1.getEnumerator();
                var listEnumerator2 = this.listItems2.getEnumerator();
                var listEnumerator3 = this.listItems3.getEnumerator();

                //iterate though all of the items
                var increment=1;
                while (listEnumerator.moveNext()) {
                    var item = listEnumerator.get_current();               
                    var title = item.get_displayName();
                    var id = item.get_id();
                    Temp(id);
                    console.log("imcrement"+increment+ "List title : " + title + "; List ID : "+ id);
                    increment = increment +1;
                  
            //alert("List title : " + title + "; List ID : "+ id);
        }
       
        function Temp(tempID)
        {
                console.log(tempID);
                //alert(tempID);
        }
       
        var increment1=1;
                                while (listEnumerator1.moveNext()) {
                    var item1 = listEnumerator1.get_current();               
                    var title1 = item1.get_displayName();
                    var id1 = item1.get_id();
                    console.log("imcrement"+increment1+ "List title : " + title1 + "; List ID : "+ id1);
                    increment1 = increment1 +1;
            //alert("List title : " + title + "; List ID : "+ id);
        }
       
        var increment2=1;
                                while (listEnumerator2.moveNext()) {
                    var item2 = listEnumerator2.get_current();               
                    var title2 = item2.get_displayName();
                    var id2 = item2.get_id();
                    console.log("imcrement"+increment2+ "List title : " + title2 + "; List ID : "+ id1);
                    increment2 = increment2 +1;
            //alert("List title : " + title + "; List ID : "+ id);
        }
       
        var increment3=1;
                                while (listEnumerator3.moveNext()) {
                                               
                    var item3 = listEnumerator3.get_current();
                    var title3 = item3.get_displayName();
                    var id3 = item3.get_id();
                    console.log("imcrement"+increment3+ "List title : " + title3 + "; List ID : "+ id3);
                    increment3 = increment3 +1;
            //alert("List title : " + title + "; List ID : "+ id);
        }
       
       

}
               
function onQueryFailed(sender, args) {
                alert('request failed ' + args.get_message() + '\n' + args.get_stackTrace());
}</script>​
</asp:Content>

No comments:

Post a Comment