<?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: Executing a feature action in a widget: what get passed? in Web AppBuilder Custom Widgets Questions</title>
    <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769244#M1492</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I added the correct require for Query and FeatureLayer (checking the spelling/ case according to the javascript API). I've included the complete code in a reply to the original post.&lt;/P&gt;&lt;P&gt;Since this is a widget, are there other files where I need to require those classes?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 02 Mar 2017 17:04:28 GMT</pubDate>
    <dc:creator>StahlyEngineering</dc:creator>
    <dc:date>2017-03-02T17:04:28Z</dc:date>
    <item>
      <title>Executing a feature action in a widget: what get passed?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769241#M1489</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have a handful of general questions about what happens when a feature action is executed.&lt;/P&gt;&lt;P&gt;I am attempting to do a query returning all features from Layer2 intersecting a selected feature from Layer1.&lt;/P&gt;&lt;P&gt;The feature action gets called from a popup that comes up after selecting a feature from Layer1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Whenever I attempt to get specific values from the featureSet or featureLayer object I get undefined results, which makes me feel that the widget doesn't get the actual selected feature as an input.&lt;/P&gt;&lt;P&gt;Additionally when I refer to Layer2 via a QuaryTask or a FeatureLayer, I am unable to display any information about Layer2.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a code snippet. How am I using featureLayer and quarytask constructors wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;onExecute: function(featureSet, featureLayer){&lt;BR /&gt; WidgetManager.getInstance().triggerWidgetOpen(this.widgetId)&lt;BR /&gt; .then(function(myWidget) {&lt;BR /&gt; //Widget Action&lt;BR /&gt; var fName = []; //useless temp array&lt;BR /&gt; fName[0] = featureSet.spatialReference.wkid; &lt;BR /&gt; fName[1] = featureSet.displayFieldName;&lt;BR /&gt; console.log('log: step 0 '+featureLayer.name);&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN&gt; SecDiv_FL = new FeatureLayer("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fservices6.arcgis.com%2F3aTanasiPG0rbYg4%2Farcgis%2Frest%2Fservices%2FPLSS_Sanders_2ndDiv%2FFeatureServer%2F0" rel="nofollow" target="_blank"&gt;http://services6.arcgis.com/3aTanasiPG0rbYg4/arcgis/rest/services/PLSS_Sanders_2ndDiv/FeatureServer/0&lt;/A&gt;&lt;SPAN&gt;");&lt;/SPAN&gt;&lt;BR /&gt; slct = featureLayer.getSelectedFeatures();&lt;BR /&gt;&lt;SPAN&gt; //var queryTask = new QueryTask("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fservices6.arcgis.com%2F3aTanasiPG0rbYg4%2Farcgis%2Frest%2Fservices%2FPLSS_Sanders_2ndDiv%2FFeatureServer%2F0" rel="nofollow" target="_blank"&gt;http://services6.arcgis.com/3aTanasiPG0rbYg4/arcgis/rest/services/PLSS_Sanders_2ndDiv/FeatureServer/0&lt;/A&gt;&lt;SPAN&gt;");&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;console.log('log: step 0.1 '+featureSet.features[0].attributes['FID']);&lt;BR /&gt; Q = new Query();&lt;BR /&gt; Q.returnGeometry = true;&lt;BR /&gt; Q.outSpatialReference = new SpatialReference({wkid:102100});&lt;BR /&gt; Q.geometry = featureSet.features[0].geometry;&lt;BR /&gt; Q.spatialRelationship = Query.SPATIAL_REL_INTERSECTS;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 00:08:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769241#M1489</guid>
      <dc:creator>StahlyEngineering</dc:creator>
      <dc:date>2017-03-02T00:08:30Z</dc:date>
    </item>
    <item>
      <title>Re: Executing a feature action in a widget: what get passed?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769242#M1490</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stahly,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Did you add the requires to your FeatureAction code for FeatureLayer, QueryTask and Query?&lt;/P&gt;&lt;P&gt;Also I do not see anywhere in your code posted where you actually use the Query (i.e. no&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;queryTask.execute or&amp;nbsp;&lt;SPAN&gt;SecDiv_FL.&lt;/SPAN&gt;&lt;/SPAN&gt;queryFeatures)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 14:15:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769242#M1490</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-03-02T14:15:15Z</dc:date>
    </item>
    <item>
      <title>Re: Executing a feature action in a widget: what get passed?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769243#M1491</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is the entire feature action code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;define([&lt;BR /&gt; "dojo/_base/declare",&lt;BR /&gt; "jimu/BaseFeatureAction",&lt;BR /&gt; "jimu/WidgetManager",&lt;BR /&gt; "esri/tasks/FeatureSet",&lt;BR /&gt; "esri/tasks/query",&lt;BR /&gt; "esri/layers/FeatureLayer",&lt;BR /&gt;], function(declare, BaseFeatureAction, WidgetManager, FeatureSet, Query, FeatureLayer){&lt;BR /&gt; var clazz = declare(BaseFeatureAction, {&lt;BR /&gt; iconFormat: 'png',&lt;BR /&gt; isFeatureSupported: function(featureSet){&lt;BR /&gt; return featureSet.displayFieldName == 'OwnerName';&lt;BR /&gt; },&lt;/P&gt;&lt;P&gt;onExecute: function(featureSet, featureLayer){&lt;BR /&gt; WidgetManager.getInstance().triggerWidgetOpen(this.widgetId)&lt;BR /&gt; .then(function(myWidget) {&lt;BR /&gt; //Widget Action&lt;BR /&gt; var fName = []; //useless temp array&lt;BR /&gt; fName[0] = featureSet.spatialReference.wkid; &lt;BR /&gt; fName[1] = featureSet.displayFieldName;&lt;BR /&gt; console.log('log: step 0 '+featureLayer.name);&lt;BR /&gt; &lt;BR /&gt;&lt;SPAN&gt; SecDiv = new FeatureLayer("&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fservices6.arcgis.com%2F3aTanasiPG0rbYg4%2Farcgis%2Frest%2Fservices%2FPLSS_Sanders_2ndDiv%2FFeatureServer%2F0" rel="nofollow" target="_blank"&gt;http://services6.arcgis.com/3aTanasiPG0rbYg4/arcgis/rest/services/PLSS_Sanders_2ndDiv/FeatureServer/0&lt;/A&gt;&lt;SPAN&gt;"); //likely broken&lt;/SPAN&gt;&lt;BR /&gt; console.log('log: step 0.1 '+featureSet.features[0].attributes.PARCELID); //works&lt;BR /&gt; console.log('log: step 0.1 '+SecDiv.name); //doesn't work&lt;BR /&gt; Q = new Query();&lt;BR /&gt; Q.geometry = featureSet.features[0].geometry;&lt;BR /&gt; Q.outFields = [ "*" ];&lt;BR /&gt; Q.spatialRelationship = Query.SPATIAL_REL_INTERSECTS; &lt;BR /&gt; Q.returnGeometry = true;&lt;BR /&gt; console.log('log: step 0.2 '+Q.geometry.type);&lt;BR /&gt; console.log('log: step 0.3 '+featureLayer.displayField);&lt;BR /&gt; SecDiv.queryFeatures(Q,function(fset){&lt;BR /&gt; console.log(fSet.features[0].attributes.SECDIVID); //should be a function of a featureset returned by queryFeatures&lt;BR /&gt; });&lt;BR /&gt; myWidget.SelectParcels(fName); //useless temp output&lt;BR /&gt; });&lt;BR /&gt; }&lt;BR /&gt; });&lt;BR /&gt; return clazz; //what does this do?&lt;BR /&gt;});&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 16:48:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769243#M1491</guid>
      <dc:creator>StahlyEngineering</dc:creator>
      <dc:date>2017-03-02T16:48:32Z</dc:date>
    </item>
    <item>
      <title>Re: Executing a feature action in a widget: what get passed?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769244#M1492</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I think I added the correct require for Query and FeatureLayer (checking the spelling/ case according to the javascript API). I've included the complete code in a reply to the original post.&lt;/P&gt;&lt;P&gt;Since this is a widget, are there other files where I need to require those classes?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 17:04:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769244#M1492</guid>
      <dc:creator>StahlyEngineering</dc:creator>
      <dc:date>2017-03-02T17:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: Executing a feature action in a widget: what get passed?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769245#M1493</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;So are you getting any of your console.log statements in your console?&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;&lt;P&gt;Since this is a widget, are there other files where I need to require those classes?&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;No just in the FeatureAction.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;SecDiv&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;queryFeatures&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;Q&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt;&lt;SPAN class="keyword token"&gt;function&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fset&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
&amp;nbsp; console&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;log&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;fSet&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;features&lt;SPAN class="punctuation token"&gt;[&lt;/SPAN&gt;&lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;]&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;attributes&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;SECDIVID&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt; &lt;SPAN class="comment token"&gt;//should be a function of a featureset returned by queryFeatures&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;in line 1 of the above code you have fset and in line 2 you use f&lt;STRONG&gt;S&lt;/STRONG&gt;et.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;console.log('log: step 0.1 '+SecDiv.name); //doesn't work&lt;/BLOCKQUOTE&gt;&lt;P&gt;Because you have not given SecDiv a name property value.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;return clazz; //what does this do?&lt;/BLOCKQUOTE&gt;&lt;P&gt;It returns the&amp;nbsp;&lt;SPAN style="background-color: #ffffff;"&gt;BaseFeatureAction declare&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 08:34:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769245#M1493</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T08:34:33Z</dc:date>
    </item>
    <item>
      <title>Re: Executing a feature action in a widget: what get passed?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769246#M1494</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;-console.log statements:&lt;/P&gt;&lt;P&gt;Yes, those all work and show the correct values in the console.&amp;nbsp;&lt;/P&gt;&lt;P&gt;- fSet, fset:&lt;/P&gt;&lt;P&gt;That appeared to be the problem (I'll learn to check letter cases one of these days)&lt;/P&gt;&lt;P&gt;-&lt;SPAN style="background-color: #ffffff;"&gt;SecDiv.name:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;So to make sure, featurelayer.name is a property that I must set when constructing the object, it's not the layer's name as it is defined in the feature layer?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="background-color: #ffffff;"&gt;I've marked the question answered.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:14:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769246#M1494</guid>
      <dc:creator>StahlyEngineering</dc:creator>
      <dc:date>2017-03-02T20:14:00Z</dc:date>
    </item>
    <item>
      <title>Re: Executing a feature action in a widget: what get passed?</title>
      <link>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769247#M1495</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Stahly,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;So to make sure, featurelayer.name is a property that I must set when constructing the object, it's not the layer's name as it is defined in the feature layer?&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;You are correct the documentation states:&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;The name of the layer as defined in the map service.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;It is likely because the FeatureLayer was not loaded before you had the console.log line. You would need to wait for the layer to fire it's load event before checking that property.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 02 Mar 2017 20:26:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/executing-a-feature-action-in-a-widget-what-get/m-p/769247#M1495</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2017-03-02T20:26:04Z</dc:date>
    </item>
  </channel>
</rss>

