<?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: How to handle QueryTask call back function in AMD module? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-handle-querytask-call-back-function-in-amd/m-p/68437#M5999</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rene,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the first approach of anonymous function but it did not work. Code in that anonymous function is not getting called. Obviously I missed something. Below is my code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;queryTask.execute(query, function(queryResults) { &lt;/P&gt;&lt;P&gt;&amp;nbsp; alert('done');&lt;/P&gt;&lt;P&gt;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please give me a sample code for this? it would be really helpful for me.I would admit that being a Silverlight API programmer, JavaScript API is bit difficult for me as this moment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;S.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 30 Jan 2015 21:28:08 GMT</pubDate>
    <dc:creator>SanajyJadhav</dc:creator>
    <dc:date>2015-01-30T21:28:08Z</dc:date>
    <item>
      <title>How to handle QueryTask call back function in AMD module?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-handle-querytask-call-back-function-in-amd/m-p/68435#M5997</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have just started learning ArcGIS API For JavaScript and Dojo AMD and I'm stuck on an issue of callback function of a query task.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a simple html page and couple of custom AMD modules inside a folder.Below is my folder structure.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="/legacyfs/online/57172_Folder Structure.png"&gt;&lt;IMG alt="Folder Structure.png" class="image-1 jive-image" height="93" src="/legacyfs/online/57172_Folder Structure.png" style="height: auto;" width="565" /&gt;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Below is my AMD module for querying feature layer added to map and I call function "queryStatesLayer" from my index.html page.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE class="javascript" name="code"&gt;define(["esri/tasks/QueryTask","esri/tasks/query","dojo/_base/lang"],function(QueryTask,Query,lang){&amp;nbsp;&amp;nbsp; &amp;nbsp; return{&amp;nbsp; &amp;nbsp; queryStatesLayer:function (sqlString,Layer,outFlds){&amp;nbsp; &amp;nbsp; var query,queryTask;&amp;nbsp; &amp;nbsp; //initialize query task &amp;nbsp; queryTask = new QueryTask(Layer.url);&amp;nbsp; &amp;nbsp; //initialize query &amp;nbsp; query = new Query(); &amp;nbsp; query.returnGeometry = true; &amp;nbsp; query.outFields = outFlds;&amp;nbsp; &amp;nbsp; //execute query &amp;nbsp; queryTask.execute(query,showResults); &amp;nbsp; },&amp;nbsp; &amp;nbsp; //query completed Callback function. &amp;nbsp; showResults: function(qryResults){ &amp;nbsp; alert("Query Completed..");&amp;nbsp; } ...&amp;nbsp; &amp;nbsp; }; }); //define function ends..&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now,my problem is I'm not being able to figure out how should I write my query completed call back function in my module.I know that the way it is written now will not be called when query is completed. And if I write it as simple function outside of &lt;STRONG&gt;return { }&lt;/STRONG&gt;;it not recognized and I get an error in the console of Mozilla Firefox.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would appreciate if I could get guidance on this issue.I want to write my query completed callback function in my custom AMD module.&lt;/P&gt;&lt;P style="min-height: 8pt; padding: 0px;"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;S.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2015 20:18:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-handle-querytask-call-back-function-in-amd/m-p/68435#M5997</guid>
      <dc:creator>SanajyJadhav</dc:creator>
      <dc:date>2015-01-30T20:18:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle QueryTask call back function in AMD module?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-handle-querytask-call-back-function-in-amd/m-p/68436#M5998</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The way you are doing it, you can just use an anonymous function in the execute method and it will work.&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14226496539289253 jive_text_macro" jivemacro_uid="_14226496539289253"&gt;&lt;P&gt;queryTask.execute(query, function(queryResults) { ... });&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or you could return the execute method.&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14226496603305058" jivemacro_uid="_14226496603305058"&gt;&lt;P&gt;return queryTask.execute(query);&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then whatever function called it could handle the callback.&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14226496798072351 jive_text_macro" jivemacro_uid="_14226496798072351"&gt;&lt;P&gt;myTaskObject.queryStatesLayer('NAME').then(function(queryResults) { ... });&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The &lt;A href="https://developers.arcgis.com/javascript/jsapi/querytask-amd.html#execute"&gt;execute&lt;/A&gt; method of a QueryTask is a Promise, handled by &lt;A href="http://dojotoolkit.org/reference-guide/1.10/dojo/Deferred.html"&gt;dojo/Deferred&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope that helps.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2015 20:28:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-handle-querytask-call-back-function-in-amd/m-p/68436#M5998</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2015-01-30T20:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle QueryTask call back function in AMD module?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-handle-querytask-call-back-function-in-amd/m-p/68437#M5999</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rene,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you for your reply.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tried the first approach of anonymous function but it did not work. Code in that anonymous function is not getting called. Obviously I missed something. Below is my code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;queryTask.execute(query, function(queryResults) { &lt;/P&gt;&lt;P&gt;&amp;nbsp; alert('done');&lt;/P&gt;&lt;P&gt;&amp;nbsp; });&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you please give me a sample code for this? it would be really helpful for me.I would admit that being a Silverlight API programmer, JavaScript API is bit difficult for me as this moment.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;S.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2015 21:28:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-handle-querytask-call-back-function-in-amd/m-p/68437#M5999</guid>
      <dc:creator>SanajyJadhav</dc:creator>
      <dc:date>2015-01-30T21:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle QueryTask call back function in AMD module?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-handle-querytask-call-back-function-in-amd/m-p/68438#M6000</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your query seems to be missing a &lt;A href="https://developers.arcgis.com/javascript/jsapi/query-amd.html#where"&gt;where &lt;/A&gt;property.&lt;/P&gt;&lt;P&gt;You can also set the &lt;A href="https://developers.arcgis.com/javascript/jsapi/query-amd.html#text"&gt;query.text&lt;/A&gt;, but I always felt it was safer to be explicit and use the where property.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you wanted all results, send a where of "1=1";&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14226538477215185" jivemacro_uid="_14226538477215185"&gt;&lt;P&gt;query.where = "1=1";&lt;/P&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is a sample from the Esri site using QueryTask and Query&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/jssamples/query_nomap.html" title="https://developers.arcgis.com/javascript/jssamples/query_nomap.html"&gt;Query data without a map | ArcGIS API for JavaScript&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2015 21:36:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-handle-querytask-call-back-function-in-amd/m-p/68438#M6000</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2015-01-30T21:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to handle QueryTask call back function in AMD module?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-handle-querytask-call-back-function-in-amd/m-p/68439#M6001</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Rene,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think I got it. I was not setting whereclause on the query object.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Appreciate your help Rene.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 30 Jan 2015 21:46:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-handle-querytask-call-back-function-in-amd/m-p/68439#M6001</guid>
      <dc:creator>SanajyJadhav</dc:creator>
      <dc:date>2015-01-30T21:46:37Z</dc:date>
    </item>
  </channel>
</rss>

