<?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: Find Task in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/find-task/m-p/764153#M963</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;James,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; The problem is a simple scope issue as your array function place its function block in a different scope and it can not find this.resultsLayer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the fix is to use lang.hitch.&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14623658139275185" data-renderedposition="138_8_1155_16" jivemacro_uid="_14623658139275185"&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;array.forEach(results, lang.hitch(this, function (result){&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 04 May 2016 12:43:36 GMT</pubDate>
    <dc:creator>RobertScheitlin__GISP</dc:creator>
    <dc:date>2016-05-04T12:43:36Z</dc:date>
    <item>
      <title>Find Task</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/find-task/m-p/764150#M960</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm creating my first custom widget using the find task. I can retrieve and display the attributes of the returned records but I'm having issues adding graphics to the map. I've created a graphicsLayer called resultsLayer and added it to the map but I keep getting the following error: &lt;STRONG&gt;TypeError: Cannot read property '_graphicsLayer' of undefined&lt;/STRONG&gt;. . Any help is appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;showFindResults: function(results){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; console.log("showFindResults");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var markerSymbol = symbolJsonUtils.fromJson(this.config.symbols.simplemarkersymbol);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var lineSymbol = symbolJsonUtils.fromJson(this.config.symbols.simplelinesymbol);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var polygonSymbol = symbolJsonUtils.fromJson(this.config.symbols.simplefillsymbol);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var resultItems = [];&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var result, attribs;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; array.forEach(results, function (result){&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; var graphic = result.feature;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; attribs = result.feature.attributes;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; resultItems.push("Compkey: " + "&amp;lt;b&amp;gt;" + attribs.COMPKEY + "&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;");&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; resultItems.push("Unitid: " + "&amp;lt;b&amp;gt;" + attribs.UNITID + "&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;");&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; resultItems.push("Layer Name: " + "&amp;lt;b&amp;gt;" + result.layerName + "&amp;lt;/b&amp;gt;&amp;lt;br&amp;gt;");&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; resultItems.push("&amp;lt;br&amp;gt;");&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; switch (graphic.geometry.type)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; {&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; case "point":&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.setSymbol(markerSymbol);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp; break;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; case "polyline":&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; graphic.setSymbol(lineSymbol);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp; break;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; case "polygon":&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; graphic.setSymbol(polygonSymbol);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp; break;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp; }&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.resultsLayer.add(graphic);&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //this.map.graphics.add(graphic);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; });&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2016 21:47:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/find-task/m-p/764150#M960</guid>
      <dc:creator>JamesKo</dc:creator>
      <dc:date>2016-05-03T21:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Find Task</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/find-task/m-p/764151#M961</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The error message sounds like you not add the &lt;A href="https://developers.arcgis.com/javascript/3/jsapi/graphicslayer-amd.html" title="https://developers.arcgis.com/javascript/3/jsapi/graphicslayer-amd.html" rel="nofollow noopener noreferrer" target="_blank"&gt;GraphicsLayer | API Reference | ArcGIS API for JavaScript&lt;/A&gt; into the Application. Or at least that application doesn't recognize this class &lt;SPAN style="color: #dd1144;"&gt;"esri/layers/GraphicsLayer" &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Would you make sure your widget js file, the dojoLoader has this class and the order is also correct?&lt;/P&gt;&lt;P&gt;For example:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;define([
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'dojo/_base/declare',
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'dojo/_base/html',
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'dijit/_WidgetsInTemplateMixin',
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'jimu/BaseWidget',
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'dijit/layout/TabContainer',
&amp;nbsp;&amp;nbsp;&amp;nbsp; "dijit/layout/ContentPane",
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'jimu/utils',
&amp;nbsp;&amp;nbsp;&amp;nbsp; 'jimu/dijit/Message',
&amp;nbsp;&amp;nbsp;&amp;nbsp; "dojo/Deferred",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "dojo/promise/all",
&amp;nbsp;&amp;nbsp;&amp;nbsp; "esri/layers/GraphicsLayer",
&amp;nbsp; ],
&amp;nbsp; function(
&amp;nbsp;&amp;nbsp;&amp;nbsp; declare,
&amp;nbsp;&amp;nbsp;&amp;nbsp; html,
&amp;nbsp;&amp;nbsp;&amp;nbsp; _WidgetsInTemplateMixin,
&amp;nbsp;&amp;nbsp;&amp;nbsp; BaseWidget,
&amp;nbsp;&amp;nbsp;&amp;nbsp; TabContainer,
&amp;nbsp;&amp;nbsp;&amp;nbsp; ContentPane,
&amp;nbsp;&amp;nbsp;&amp;nbsp; utils,
&amp;nbsp;&amp;nbsp;&amp;nbsp; Message,
&amp;nbsp;&amp;nbsp;&amp;nbsp; Deferred,
&amp;nbsp;&amp;nbsp;&amp;nbsp; all,
&amp;nbsp;&amp;nbsp;&amp;nbsp; GraphicsLayer,&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:28:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/find-task/m-p/764151#M961</guid>
      <dc:creator>YueWu1</dc:creator>
      <dc:date>2021-12-12T08:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: Find Task</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/find-task/m-p/764152#M962</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your reply. That was one of the first things I checked...Have a look below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;define(['dojo/_base/declare',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'jimu/BaseWidget',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'dijit/_WidgetsInTemplateMixin',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'dijit/form/TextBox',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'dijit/ProgressBar',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'dojo/on',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'dojo/_base/array',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'dojo/_base/lang',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'dojo/_base/html',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'esri/layers/GraphicsLayer',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'esri/graphic',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'esri/graphicsUtils',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'esri/tasks/query',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'esri/tasks/QueryTask',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'esri/tasks/FindParameters',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'esri/tasks/FindTask',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'esri/tasks/FindResult',&lt;/P&gt;&lt;P&gt;&amp;nbsp; "esri/symbols/jsonUtils",&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'esri/symbols/SimpleMarkerSymbol',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'esri/symbols/SimpleLineSymbol',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'esri/symbols/SimpleFillSymbol',&lt;/P&gt;&lt;P&gt;&amp;nbsp; 'esri/Color'],&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; function(declare, BaseWidget, _WidgetsInTemplateMixin, TextBox, ProgressBar, on, array, lang, html, GraphicsLayer,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Graphic, graphicsUtils, Query, QueryTask, FindParameters, FindTask, FindResult, symbolJsonUtils,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, Color)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 May 2016 23:35:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/find-task/m-p/764152#M962</guid>
      <dc:creator>JamesKo</dc:creator>
      <dc:date>2016-05-03T23:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Find Task</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/find-task/m-p/764153#M963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;James,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; The problem is a simple scope issue as your array function place its function block in a different scope and it can not find this.resultsLayer.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;the fix is to use lang.hitch.&lt;/P&gt;&lt;PRE __default_attr="javascript" __jive_macro_name="code" class="jive_macro_code jive_text_macro _jivemacro_uid_14623658139275185" data-renderedposition="138_8_1155_16" jivemacro_uid="_14623658139275185"&gt;&lt;SPAN style="color: #3d3d3d; font-family: arial, helvetica, 'helvetica neue', verdana, sans-serif;"&gt;array.forEach(results, lang.hitch(this, function (result){&lt;/SPAN&gt;&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 May 2016 12:43:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/find-task/m-p/764153#M963</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2016-05-04T12:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: Find Task</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/find-task/m-p/764154#M964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Robert, that was it!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 May 2016 15:56:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/find-task/m-p/764154#M964</guid>
      <dc:creator>JamesKo</dc:creator>
      <dc:date>2016-05-04T15:56:23Z</dc:date>
    </item>
  </channel>
</rss>

