<?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 Access fields inside widget object? in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/access-fields-inside-widget-object/m-p/852762#M11042</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is probably best asked by stating an example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The out-of-the-box Query widget contains a variable called &lt;STRONG&gt;tempResultLayer&lt;/STRONG&gt;. I have another custom widget which would like to access this layer directly once it's been created by the query. I could go through map.getLayer(), but it seems there's no predictable layerId to reference it with, as the layerId appears to be generated on the fly with each query. The custom widget needs to collect an attribute value from each of the features returned by the query. (Alternatively, if there's a more straightforward way of accomplishing this without customizing the Query widget itself, I'm more than open to suggestions.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the question is - does the app builder support a means of accessing widget objects in this way, and getting at variables declared inside of them? I don't see any documentation this sort of access, or any other example of accessing app builder variables programmatically other than the &lt;EM&gt;this.map.id&lt;/EM&gt; example in the tutorial.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 11 Feb 2015 19:41:33 GMT</pubDate>
    <dc:creator>AnthonyPreston1</dc:creator>
    <dc:date>2015-02-11T19:41:33Z</dc:date>
    <item>
      <title>Access fields inside widget object?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/access-fields-inside-widget-object/m-p/852762#M11042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This is probably best asked by stating an example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The out-of-the-box Query widget contains a variable called &lt;STRONG&gt;tempResultLayer&lt;/STRONG&gt;. I have another custom widget which would like to access this layer directly once it's been created by the query. I could go through map.getLayer(), but it seems there's no predictable layerId to reference it with, as the layerId appears to be generated on the fly with each query. The custom widget needs to collect an attribute value from each of the features returned by the query. (Alternatively, if there's a more straightforward way of accomplishing this without customizing the Query widget itself, I'm more than open to suggestions.)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So the question is - does the app builder support a means of accessing widget objects in this way, and getting at variables declared inside of them? I don't see any documentation this sort of access, or any other example of accessing app builder variables programmatically other than the &lt;EM&gt;this.map.id&lt;/EM&gt; example in the tutorial.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 19:41:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/access-fields-inside-widget-object/m-p/852762#M11042</guid>
      <dc:creator>AnthonyPreston1</dc:creator>
      <dc:date>2015-02-11T19:41:33Z</dc:date>
    </item>
    <item>
      <title>Re: Access fields inside widget object?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/access-fields-inside-widget-object/m-p/852763#M11043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Anthony,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All webapp builder widgets are dojo dijits.&lt;/P&gt;&lt;P&gt;Therefore, you can access a widget with dijit.byId(widget_id) :&lt;/P&gt;&lt;P&gt;var tmpLayer = dijit.byId("widget_id").tempResultLayer;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;With this solution, you need to know the id of the out-of-the-box Query widget.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So you can use the widget manager (method getWidgetsByName) to get the search widget :&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/web-appbuilder/api-reference/widgetmanager.htm" title="https://developers.arcgis.com/web-appbuilder/api-reference/widgetmanager.htm"&gt;https://developers.arcgis.com/web-appbuilder/api-reference/widgetmanager.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Last but not least, you can use the communication system between widgets :&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/web-appbuilder/guide/communication-between-widgets.htm" title="https://developers.arcgis.com/web-appbuilder/guide/communication-between-widgets.htm"&gt;https://developers.arcgis.com/web-appbuilder/guide/communication-between-widgets.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;In this case, you have to modify the query widget (add publishData when necessary).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 11 Feb 2015 23:13:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/access-fields-inside-widget-object/m-p/852763#M11043</guid>
      <dc:creator>JeremieCornet1</dc:creator>
      <dc:date>2015-02-11T23:13:26Z</dc:date>
    </item>
    <item>
      <title>Re: Access fields inside widget object?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/access-fields-inside-widget-object/m-p/852764#M11044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;This pointed me in the right direction, thanks.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once including the WidgetManager, the following worked to get at the Query widget:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;wm = WidgetManager.getInstance();&lt;/P&gt;&lt;P&gt;q = wm.getWidgetsByName("Query");&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, index [0] of "q" is the actual instance of the widget.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also, it turns out, I needed to use .queryResults.resultLayer instead of tempResultsLayer, for anyone else who might be aiming to do something similar. The latter doesn't persist beyond the query operation itself, it appears.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 12 Feb 2015 00:04:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/access-fields-inside-widget-object/m-p/852764#M11044</guid>
      <dc:creator>AnthonyPreston1</dc:creator>
      <dc:date>2015-02-12T00:04:14Z</dc:date>
    </item>
  </channel>
</rss>

