<?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 consume the data in a function from the fetchData method? in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798507#M4937</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are the man Robert! Works like a charm. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 20 Dec 2017 21:29:22 GMT</pubDate>
    <dc:creator>MartinOwens1</dc:creator>
    <dc:date>2017-12-20T21:29:22Z</dc:date>
    <item>
      <title>How to consume the data in a function from the fetchData method?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798501#M4931</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm using the Enhanced Search widget to pass a value from a feature using the publishData method to another widget. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sending Widget:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.publishData({&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data: feature.attributes["PARID"],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; keepHistory: true&lt;/P&gt;&lt;P&gt;&amp;nbsp; })&lt;/P&gt;&lt;P&gt;I'm using the onReceiveData function in the other widget to grab the data. If I write to the console under this function it gets the value, but when I try to consume it in a different function it doesn't retun the data. I've tried setting it to a global variable and still nothing. I have no idea what is wrong:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Receiving widget:&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; startup: function() {&lt;BR /&gt; this.inherited(arguments);&lt;BR /&gt; this.fetchDataByName('eSearch');&lt;BR /&gt; &lt;BR /&gt; //console.log('startup');&lt;BR /&gt; },&lt;/P&gt;&lt;P&gt;onReceiveData: function(name, widgetId, data, historyData) {&lt;BR /&gt; //filter out messages&lt;BR /&gt; if(name !== 'eSearch'){&lt;BR /&gt; return;&lt;BR /&gt; }&lt;BR /&gt; window.ParcelData = data; &lt;BR /&gt; &lt;BR /&gt; console.log(ParcelData);&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;lt;THIS WORKS&amp;gt;&lt;BR /&gt; }, &lt;BR /&gt; onOpen: function(){&lt;BR /&gt; console.log('onOpen');&lt;BR /&gt; require(["dijit/layout/TabContainer", "dijit/layout/ContentPane", "dojo/domReady!"], function(TabContainer, ContentPane){&lt;BR /&gt; &lt;BR /&gt; var tc = new TabContainer({&lt;BR /&gt; style: "height: 100%; width: 100%;"&lt;BR /&gt; }, "tc1-prog");&lt;BR /&gt; &lt;BR /&gt; var cp1 = new ContentPane({&lt;BR /&gt; title: "Parcel Info",&lt;BR /&gt; content: "&amp;lt;div id='parcelPropInfo'&amp;gt;&amp;lt;/div&amp;gt;"&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; tc.addChild(cp1);&lt;BR /&gt; &lt;BR /&gt; var cp2 = new ContentPane({&lt;BR /&gt; title: "Building Info",&lt;BR /&gt; content: "&amp;lt;div id='parcelBldgInfo'&amp;gt;&amp;lt;/div&amp;gt;"&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; tc.addChild(cp2);&lt;BR /&gt; tc.startup();&lt;BR /&gt; });&lt;BR /&gt; &lt;BR /&gt; // parcelPropInfo&lt;BR /&gt; dojo.ready(function(){&lt;BR /&gt; // Look up the node we'll stick the text under.&lt;BR /&gt; var targetNode = dojo.byId("parcelPropInfo");&lt;BR /&gt; &lt;BR /&gt; // The parameters to pass to xhrGet, the url, how to handle it, and the callbacks.&lt;BR /&gt; var xhrArgs = {&lt;BR /&gt; //url: "./widgets/Demo/resources/parcelPropInfo.aspx?parid=A02000200230000400",&lt;BR /&gt; url: "./widgets/Demo/resources/parcelPropInfo.aspx?parid=" + ParcelData,&amp;nbsp; &amp;lt;THIS DOES NOT&amp;gt;&lt;BR /&gt; handleAs: "text",&lt;BR /&gt; load: function(data){&lt;BR /&gt; // Replace newlines with nice HTML tags.&lt;BR /&gt; //data = data.replace(/\n/g, "&amp;lt;br&amp;gt;");&lt;BR /&gt; &lt;BR /&gt; // Replace tabs with spaces.&lt;BR /&gt; //data = data.replace(/\t/g, "&amp;nbsp;&amp;nbsp;&amp;nbsp;");&lt;BR /&gt; &lt;BR /&gt; targetNode.innerHTML = data;&lt;BR /&gt; //return data;&lt;BR /&gt; },&lt;BR /&gt; &lt;BR /&gt; error: function(error){&lt;BR /&gt; targetNode.innerHTML = "An unexpected error occurred: " + error;&lt;BR /&gt; //return "An unexpected error occurred: " + error;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Dec 2017 18:57:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798501#M4931</guid>
      <dc:creator>MartinOwens1</dc:creator>
      <dc:date>2017-12-20T18:57:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to consume the data in a function from the fetchData method?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798502#M4932</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;url: "./widgets/Demo/resources/parcelPropInfo.aspx?parid=" + ParcelData,&amp;nbsp; &amp;lt;THIS DOES NOT&amp;gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;Shouldn't that be window.&lt;SPAN&gt;ParcelData not&amp;nbsp;ParcelData?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Dec 2017 19:03:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798502#M4932</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-12-20T19:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to consume the data in a function from the fetchData method?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798503#M4933</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I attempted that as well and still no success.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Dec 2017 19:35:09 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798503#M4933</guid>
      <dc:creator>MartinOwens1</dc:creator>
      <dc:date>2017-12-20T19:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: How to consume the data in a function from the fetchData method?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798504#M4934</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;I don't think I have ever seen anyone use dojo.ready in a widget before. The issue is that that function will have a different scope then the rest of the widget code. Why are you not doing all that stuff (now in the dojo.ready function) inside the widgets startup? Also widget based global vars are created using this.&lt;SPAN style="background-color: #ffffff;"&gt;ParcelData. Unless you need this var to be available inside the whole app then there is no need to use window.&lt;SPAN&gt;ParcelData.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Dec 2017 20:03:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798504#M4934</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-12-20T20:03:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to consume the data in a function from the fetchData method?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798505#M4935</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Adding the dojo.ready functions to the startup doesn't seem to have any effect on the result. I made the change on variable I think during troubleshooting obtaining the value. I've set it now using this.ParcelData. Would you have any other ideas on how to pass the object sting to the url the dojo function?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Dec 2017 20:31:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798505#M4935</guid>
      <dc:creator>MartinOwens1</dc:creator>
      <dc:date>2017-12-20T20:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to consume the data in a function from the fetchData method?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798506#M4936</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Martin,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;OK, Actually that makes sense. The startup function is not going to have this.&lt;SPAN style="background-color: #ffffff;"&gt;ParcelData yet because it is still null when the widget is started up. How about moving your xhr stuff to the&amp;nbsp;&lt;SPAN&gt;onReceiveData?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Dec 2017 20:44:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798506#M4936</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-12-20T20:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: How to consume the data in a function from the fetchData method?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798507#M4937</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You are the man Robert! Works like a charm. Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 20 Dec 2017 21:29:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/how-to-consume-the-data-in-a-function-from-the/m-p/798507#M4937</guid>
      <dc:creator>MartinOwens1</dc:creator>
      <dc:date>2017-12-20T21:29:22Z</dc:date>
    </item>
  </channel>
</rss>

