<?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 Query Loop in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-loop/m-p/296655#M27253</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi everybody,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I need to run a loop inside where I run some query (queryTask.execute(...)) on a Feature Layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As you know, queries run in rapid sequence may terminate in different order then the original. A possible solution I found is to use a callback function that add the results (everytime is called) to a global array and at the end we can find those results in that array. But at this point I get an issue, I don't know exactly when all the queries are terminated, so I can't actually use the queries' results. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to use dojo.connect(...) to connect the onComplete event of every query run to the function that add the results to the global array but this doesn't work properly and furthermore I still don't know when exactly all the queries terminate.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you got any idea?have someone ever got this issue?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you everybody.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Feb 2012 16:27:13 GMT</pubDate>
    <dc:creator>demdeberanz</dc:creator>
    <dc:date>2012-02-28T16:27:13Z</dc:date>
    <item>
      <title>Query Loop</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-loop/m-p/296655#M27253</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi everybody,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I need to run a loop inside where I run some query (queryTask.execute(...)) on a Feature Layer.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;As you know, queries run in rapid sequence may terminate in different order then the original. A possible solution I found is to use a callback function that add the results (everytime is called) to a global array and at the end we can find those results in that array. But at this point I get an issue, I don't know exactly when all the queries are terminated, so I can't actually use the queries' results. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to use dojo.connect(...) to connect the onComplete event of every query run to the function that add the results to the global array but this doesn't work properly and furthermore I still don't know when exactly all the queries terminate.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Have you got any idea?have someone ever got this issue?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you everybody.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2012 16:27:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-loop/m-p/296655#M27253</guid>
      <dc:creator>demdeberanz</dc:creator>
      <dc:date>2012-02-28T16:27:13Z</dc:date>
    </item>
    <item>
      <title>Re: Query Loop</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-loop/m-p/296656#M27254</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;We have a sample showing how to handle the results from multiple query tasks:&amp;nbsp; &lt;/SPAN&gt;&lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/query_deferred_list.html"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/query_deferred_list.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If you need to run multiple queries, manage them with a deferredList.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Feb 2012 16:40:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-loop/m-p/296656#M27254</guid>
      <dc:creator>derekswingley1</dc:creator>
      <dc:date>2012-02-28T16:40:02Z</dc:date>
    </item>
    <item>
      <title>Re: Query Loop</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-loop/m-p/296657#M27255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;We have a sample showing how to handle the results from multiple query tasks:&amp;nbsp; &lt;A href="http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/query_deferred_list.html"&gt;http://help.arcgis.com/en/webapi/javascript/arcgis/help/jssamples/query_deferred_list.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;If you need to run multiple queries, manage them with a deferredList.&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;SPAN&gt; &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you for your help!:) this solution works properly! But now I've got another issue, I need to associate to each query an id that depends on a variable. &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;How can I do this? (at the beginning I used dojo.hitch function to pass other than the results also this id&amp;nbsp; ex.: queryTask.execute(query,dojo.hitch(...)) )&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thank you very much.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Feb 2012 06:18:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-loop/m-p/296657#M27255</guid>
      <dc:creator>demdeberanz</dc:creator>
      <dc:date>2012-02-29T06:18:09Z</dc:date>
    </item>
    <item>
      <title>Re: Query Loop</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-loop/m-p/296658#M27256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Here's how to do this. You need to create a closure to capture the actual query identifier; but since closures are not created until they function whose data they represent is actually executed, you need to create and call an inline function:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // function is executed immediately and passed the value of i, which creates&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // the closure *during* loop evaluation so the value of i is different for each closure.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (function (value) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; qt.execute(q)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; .then(function (featureset) {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; processReturn(featureset, i);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; });&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; })(i);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;where i is my array index variable from the 'for' loop.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Steve G.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Mar 2012 22:22:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/query-loop/m-p/296658#M27256</guid>
      <dc:creator>StevenGriffith</dc:creator>
      <dc:date>2012-03-05T22:22:07Z</dc:date>
    </item>
  </channel>
</rss>

