<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: An issue about featureLayer1.queryFeatures containing featureLayer2.queryFeatures in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/an-issue-about-featurelayer1-queryfeatures/m-p/1090917#M74361</link>
    <description>&lt;P&gt;Thank you so much for your reply. I read the article about chaining promises already, but mine is that VLLayer.queryFeatures() is inside of PDLayer.queryFeatures(), and also the result of PDLayer.queryFeatures() is used as query "where" condition of&amp;nbsp;VLLayer.queryFeatures(). Do you think if chaining promise is going to work for this situation? Thanks for your help!&lt;/P&gt;&lt;P&gt;Saili&lt;/P&gt;</description>
    <pubDate>Fri, 20 Aug 2021 18:59:08 GMT</pubDate>
    <dc:creator>SailiTang1</dc:creator>
    <dc:date>2021-08-20T18:59:08Z</dc:date>
    <item>
      <title>An issue about featureLayer1.queryFeatures containing featureLayer2.queryFeatures</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/an-issue-about-featurelayer1-queryfeatures/m-p/1089371#M74298</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using ArcGIS JSAPI 4.20 to develop a web application. There is one function that is exporting an attribute table as HTML (Please see the screenshot below.) Attributes “&lt;STRONG&gt;Polling Division&lt;/STRONG&gt;”, “&lt;STRONG&gt;Elector Count&lt;/STRONG&gt;” and “&lt;STRONG&gt;Assign To&lt;/STRONG&gt;” are from one Feature layer; the rest attributes including “&lt;STRONG&gt;Assign To&lt;/STRONG&gt;” are belonging to the other feature layer, which means that these 2 feature layers can use the same attribute “&lt;STRONG&gt;Assign To&lt;/STRONG&gt;” to join together (but I didn’t join them together). A value of “&lt;STRONG&gt;Assign To&lt;/STRONG&gt;” is the index number of a location.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SailiTang1_0-1629137835352.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/20932i259F289AC7AB3BD0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SailiTang1_0-1629137835352.png" alt="SailiTang1_0-1629137835352.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;You can see that all the values from feature layer 2 are “undefined”. I know why but I don’t know how to fix it. I understand that it should finish running all code outside of query because of the promise of QueryFeatures, but I need VLLayer.queryFeatures to run first and return the values from Feature layer 2 (VLLayer) to build the html table. What’s the way we usually use to realize this purpose? Thanks for your help.&lt;/P&gt;&lt;P&gt;This is my jquery code:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;$("#btnExportTable").click(function () {
                //**********************************************

                var htmlToPrint = '' +
                    '&amp;lt;style type="text/css"&amp;gt;' +
                    'table { ' +
                    'font-family: arial, sans-serif;' +
                    'border-collapse: collapse;' +
                    'background-color: #f0f9fc;' +
                    'width: 80%;' +
                    'margin-left:auto;' +
                    'margin-right:auto;' +
                    ' } ' +
                    'td {' +
                    'border:1px;' +
                    'text-align: center;' +
                    'padding: 5px;' +
                    'font-size: 12px;' +
                    ' } ' +
                    'tr:nth-child(even) {' +
                    'background-color: #92c8da;' +
                    ' } ' +
                    'tr {' +
                    'page-break-inside: avoid;' +
                    ' } ' +
                    'th {' +
                    'font-size: 13px;' +
                    'font-weight: bold;' +
                    ' } ' +
                    '&amp;lt;/style&amp;gt;' +
                    '&amp;lt;h1 style="font-weight:bold;font-size:medium; text-align:center"&amp;gt;Voting Location Assignment&amp;lt;/h1&amp;gt;' +
                    '&amp;lt;p style="font-weight:bold;font-size:medium; text-align:center"&amp;gt;Electoral District of ' + edName + '&amp;lt;/p&amp;gt;';

                var header = "&amp;lt;table&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;Polling Division&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Elector Count&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Assign To&amp;lt;/th&amp;gt;" +
                    "&amp;lt;th&amp;gt;Building Name&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Landlord Name&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Landlord Phone&amp;lt;/th&amp;gt;" +
                    "&amp;lt;th&amp;gt;Landlord Email&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Manager Name&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Manager Phone&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;Manager Email&amp;lt;/th&amp;gt;" +
                    "&amp;lt;/tr &amp;gt; ";
                var end = "&amp;lt;/table&amp;gt;";
                htmlToPrint += header;

                var assignTo=[], buildingName = [], landlordName = [], landlordPhone = [], landlordEmail = [], managerName = [], managerPhone = [], managerEmail = [];


                let PDQuery = PDLayer.createQuery();
                PDQuery.where = "ED_NO= '" + edNO + "'";
                PDQuery.orderByFields = ["PD_NO ASC"];
                PDLayer.queryFeatures(PDQuery).then(function (result) {

                    for (let i = 0; i &amp;lt; result.features.length; i++) {
                        
                        if (result.features[i].attributes["VLIndex"] != null) {

                            let vlQuery = VLLayer.createQuery();
                            vlQuery.returnGeometry = false;
                            vlQuery.where = "VLIndexNum='" + result.features[i].attributes["VLIndex"] + "'";
                            VLLayer.queryFeatures(vlQuery).then(function (VLresult) {
                                
                                if (VLresult.features.length != 0) {

                                    assignTo[i] = VLresult.features[0].attributes["VLIndex"];
                                    buildingName[i] =VLresult.features[0].attributes["BUILDING_NAME"];
                                    landlordName[i] =VLresult.features[0].attributes["LANDLORDNAME"];
                                    landlordPhone[i] =VLresult.features[0].attributes["LANDLORDPHONE1"];
                                    landlordEmail[i] =VLresult.features[0].attributes["LANDLORDEMAIL"];
                                    managerName[i] =VLresult.features[0].attributes["MANAGERNAME"];
                                    managerPhone[i] =VLresult.features[0].attributes["MANAGERPHONE1"];
                                    managerEmail[i] =VLresult.features[0].attributes["MANAGEREMAIL"];

                                    
                                }

                            });

                        }
                        

                        htmlToPrint += "&amp;lt;tr&amp;gt;&amp;lt;td&amp;gt;" + result.features[i].attributes["PD_NO"] + "&amp;lt;/td&amp;gt;" +
                            "&amp;lt;td&amp;gt;" + result.features[i].attributes["electorcount"] + "&amp;lt;/td&amp;gt;" +
                            "&amp;lt;td&amp;gt;" + assignTo[i] + "&amp;lt;/td&amp;gt;" +
                            "&amp;lt;td&amp;gt;" + buildingName[i] + "&amp;lt;/td&amp;gt;" +
                            "&amp;lt;td&amp;gt;" + landlordName[i] + "&amp;lt;/td&amp;gt;" +
                            "&amp;lt;td&amp;gt;" + landlordPhone[i] + "&amp;lt;/td&amp;gt;" +
                            "&amp;lt;td&amp;gt;" + landlordEmail[i] + "&amp;lt;/td&amp;gt;" +
                            "&amp;lt;td&amp;gt;" + managerName[i] + "&amp;lt;/td&amp;gt;" +
                            "&amp;lt;td&amp;gt;" + managerPhone[i] + "&amp;lt;/td&amp;gt;" +
                            "&amp;lt;td&amp;gt;" + managerEmail[i] + "&amp;lt;/td&amp;gt;" +
                            "&amp;lt;/tr&amp;gt;";

                    };

                    htmlToPrint = htmlToPrint + end;

                    var newWin = window.open("");
                    newWin.document.write(htmlToPrint);
                    newWin.print();

                });

            });&lt;/LI-CODE&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Saili&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 18:28:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/an-issue-about-featurelayer1-queryfeatures/m-p/1089371#M74298</guid>
      <dc:creator>SailiTang1</dc:creator>
      <dc:date>2021-08-16T18:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: An issue about featureLayer1.queryFeatures containing featureLayer2.queryFeatures</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/an-issue-about-featurelayer1-queryfeatures/m-p/1089407#M74301</link>
      <description>&lt;P&gt;There's a &lt;A href="https://developers.arcgis.com/javascript/latest/programming-patterns/#promises" target="_self"&gt;section&lt;/A&gt; in the documentation about chaining promises that you should review. An alternative if you're using a newer version of JavaScript would be using &lt;A href="https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Asynchronous/Async_await" target="_self"&gt;async functions&lt;/A&gt; and the await keyword&lt;/P&gt;</description>
      <pubDate>Mon, 16 Aug 2021 20:05:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/an-issue-about-featurelayer1-queryfeatures/m-p/1089407#M74301</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-08-16T20:05:14Z</dc:date>
    </item>
    <item>
      <title>Re: An issue about featureLayer1.queryFeatures containing featureLayer2.queryFeatures</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/an-issue-about-featurelayer1-queryfeatures/m-p/1090917#M74361</link>
      <description>&lt;P&gt;Thank you so much for your reply. I read the article about chaining promises already, but mine is that VLLayer.queryFeatures() is inside of PDLayer.queryFeatures(), and also the result of PDLayer.queryFeatures() is used as query "where" condition of&amp;nbsp;VLLayer.queryFeatures(). Do you think if chaining promise is going to work for this situation? Thanks for your help!&lt;/P&gt;&lt;P&gt;Saili&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 18:59:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/an-issue-about-featurelayer1-queryfeatures/m-p/1090917#M74361</guid>
      <dc:creator>SailiTang1</dc:creator>
      <dc:date>2021-08-20T18:59:08Z</dc:date>
    </item>
  </channel>
</rss>

