<?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: Call a function within queryTask showResults in ArcGIS Web AppBuilder Questions</title>
    <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/call-a-function-within-querytask-showresults/m-p/631957#M16709</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much! You saved my day!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 20 May 2016 15:56:13 GMT</pubDate>
    <dc:creator>Alexwang</dc:creator>
    <dc:date>2016-05-20T15:56:13Z</dc:date>
    <item>
      <title>Call a function within queryTask showResults</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/call-a-function-within-querytask-showresults/m-p/631955#M16707</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I am very new to the WAB and dojo stuff. I really had a hard time with my first custom widget project. Please see below for a snippet of the codes. When I test the widget, an error appeared "TypeError: this.somethingElse() is not a function" within the _showResults. So how to make a call within _showResults and pass parameters to it? Thanks for your help!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #9b703f;"&gt;_query&lt;/SPAN&gt;&lt;SPAN style="color: #cda869;"&gt;: function(&lt;/SPAN&gt;){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #cda869;"&gt;var &lt;/SPAN&gt;&lt;SPAN style="color: #7587a6;"&gt;query &lt;/SPAN&gt;&lt;SPAN style="color: #cda869;"&gt;= new &lt;/SPAN&gt;&lt;SPAN style="color: #7587a6;"&gt;Query&lt;/SPAN&gt;();&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #7587a6;"&gt;query&lt;/SPAN&gt;.&lt;SPAN style="color: #7587a6;"&gt;where &lt;/SPAN&gt;&lt;SPAN style="color: #cda869;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="color: #8f9d6a;"&gt;"Id &amp;gt; 0"&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #7587a6;"&gt;query&lt;/SPAN&gt;.&lt;SPAN style="color: #7587a6;"&gt;outFields &lt;/SPAN&gt;&lt;SPAN style="color: #cda869;"&gt;= &lt;/SPAN&gt;[&lt;SPAN style="color: #8f9d6a;"&gt;"ID"&lt;/SPAN&gt;, &lt;SPAN style="color: #8f9d6a;"&gt;"Name"&lt;/SPAN&gt;];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #7587a6;"&gt;query&lt;/SPAN&gt;.&lt;SPAN style="color: #7587a6;"&gt;returnGeometry &lt;/SPAN&gt;&lt;SPAN style="color: #cda869;"&gt;= true&lt;/SPAN&gt;;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #cda869;"&gt;var &lt;/SPAN&gt;&lt;SPAN style="color: #7587a6;"&gt;queryTask &lt;/SPAN&gt;&lt;SPAN style="color: #cda869;"&gt;= new &lt;/SPAN&gt;&lt;SPAN style="color: #7587a6;"&gt;QueryTask&lt;/SPAN&gt;(&lt;SPAN style="color: #7587a6;"&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F" rel="nofollow" target="_blank"&gt;http://&lt;/A&gt;&lt;SPAN&gt;.....'&lt;/SPAN&gt;&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #7587a6;"&gt;queryTask&lt;/SPAN&gt;.on(&lt;SPAN style="color: #8f9d6a;"&gt;"complete"&lt;/SPAN&gt;, &lt;SPAN style="color: #cda869;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9b703f;"&gt;_queryTaskExecuteCompleteHandler&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #7587a6;"&gt;queryTask&lt;/SPAN&gt;.on(&lt;SPAN style="color: #8f9d6a;"&gt;"error"&lt;/SPAN&gt;, &lt;SPAN style="color: #cda869;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9b703f;"&gt;_queryTaskErrorHandler&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #7587a6;"&gt;queryTask&lt;/SPAN&gt;.execute(&lt;SPAN style="color: #7587a6;"&gt;query&lt;/SPAN&gt;, &lt;SPAN style="color: #cda869;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9b703f;"&gt;_showResults&lt;/SPAN&gt;);&lt;/P&gt;&lt;P&gt;},&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #9b703f;"&gt;_showResults&lt;/SPAN&gt;&lt;SPAN style="color: #cda869;"&gt;: function&lt;/SPAN&gt;(&lt;SPAN style="color: #7587a6;"&gt;featureSet&lt;/SPAN&gt;){&lt;/P&gt;&lt;P&gt;//do something here...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;SPAN style="color: #cda869;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="color: #9b703f;"&gt;_somethingElse&lt;/SPAN&gt;(&lt;SPAN style="color: #7587a6;"&gt;featureSet&lt;/SPAN&gt;.features);&lt;/P&gt;&lt;P&gt;},&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #9b703f;"&gt;_somethingElse&lt;/SPAN&gt;&lt;SPAN style="color: #cda869;"&gt;: function&lt;/SPAN&gt;(&lt;SPAN style="color: #7587a6;"&gt;features&lt;/SPAN&gt;){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; console.log(features.length);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //and do something else here&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 15:05:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/call-a-function-within-querytask-showresults/m-p/631955#M16707</guid>
      <dc:creator>Alexwang</dc:creator>
      <dc:date>2016-05-20T15:05:22Z</dc:date>
    </item>
    <item>
      <title>Re: Call a function within queryTask showResults</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/call-a-function-within-querytask-showresults/m-p/631956#M16708</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Alex,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; This is a code scope issue and you need to use and understand dojos lang.hitch.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #9b703f;"&gt;_query&lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #cda869;"&gt;: function(&lt;/SPAN&gt;){
&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #cda869;"&gt;var &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;query &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #cda869;"&gt;= new &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;Query&lt;/SPAN&gt;();
&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;query&lt;/SPAN&gt;.&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;where &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #cda869;"&gt;= &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #8f9d6a;"&gt;"Id &amp;gt; 0"&lt;/SPAN&gt;;
&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;query&lt;/SPAN&gt;.&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;outFields &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #cda869;"&gt;= &lt;/SPAN&gt;[&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #8f9d6a;"&gt;"ID"&lt;/SPAN&gt;, &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #8f9d6a;"&gt;"Name"&lt;/SPAN&gt;];
&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;query&lt;/SPAN&gt;.&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;returnGeometry &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #cda869;"&gt;= true&lt;/SPAN&gt;;

&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #cda869;"&gt;var &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;queryTask &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #cda869;"&gt;= new &lt;/SPAN&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;QueryTask&lt;/SPAN&gt;(&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;'&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2F" style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #287433;" target="_blank"&gt;http://&lt;/A&gt;&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit;"&gt;.....'&lt;/SPAN&gt;&lt;/SPAN&gt;);
&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;queryTask&lt;/SPAN&gt;.on(&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #8f9d6a;"&gt;"complete"&lt;/SPAN&gt;, &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #cda869;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #9b703f;"&gt;_queryTaskExecuteCompleteHandler&lt;/SPAN&gt;);
&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;queryTask&lt;/SPAN&gt;.on(&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #8f9d6a;"&gt;"error"&lt;/SPAN&gt;, &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #cda869;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #9b703f;"&gt;_queryTaskErrorHandler&lt;/SPAN&gt;);
&amp;nbsp;&amp;nbsp; &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;queryTask&lt;/SPAN&gt;.execute(&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #7587a6;"&gt;query&lt;/SPAN&gt;, lang.hitch(this, &lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #cda869;"&gt;this&lt;/SPAN&gt;.&lt;SPAN style="font-weight: inherit; font-style: inherit; font-family: inherit; color: #9b703f;"&gt;_showResults&lt;/SPAN&gt;));
},&lt;/PRE&gt;&lt;P&gt;So what is going on here is that "this" is a different scope when you call _showResults and because "this" is a different scope that means that is can not find the this.somethingelse function. When you use lang.hitch it preserves the scope of "this" so that it can find this.something else. Be sure to add the require for lang to your widget ("dojo/_base/lang"). &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 02:53:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/call-a-function-within-querytask-showresults/m-p/631956#M16708</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T02:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: Call a function within queryTask showResults</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/call-a-function-within-querytask-showresults/m-p/631957#M16709</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you so much! You saved my day!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 20 May 2016 15:56:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/call-a-function-within-querytask-showresults/m-p/631957#M16709</guid>
      <dc:creator>Alexwang</dc:creator>
      <dc:date>2016-05-20T15:56:13Z</dc:date>
    </item>
  </channel>
</rss>

