Select to view content in your preferred language

widget action sometimes does not trigger for supported features

2068
15
07-18-2017 01:16 PM
StahlyEngineering
Regular Contributor

I've created a custom widget that should execute a feature action for a specific feature class, checked for by the display field name.

When the widget is first added to a web app, everything works well. However if the app is saved and reloaded the feature action does not come up.

Are there specific locations where I should look for mismatched file names or something similar?

The browser (up to date Chrome) console does not report of any errors when attempting to add the widget to an app or selecting the target feature class.

(edit):

Doing any changes to the feature action .js file, including changing a comment or whitespace, saving the file and reloading the app allows the widget to work as intended until the app is reloaded again.

Thanks!

0 Kudos
15 Replies
StahlyEngineering
Regular Contributor

No, the js file name is TSRecordsAction.

here's the relevant chunk of the manifest file:

},
"featureActions": [{
"name": "TSRecords",
"uri": "TSRecordsAction"
}]

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Try changing them to be identical.

0 Kudos
StahlyEngineering
Regular Contributor

I've done so and that does not seem to make a difference

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

What does your TSRecordsAction.js look like?

0 Kudos
StahlyEngineering
Regular Contributor

define([
   "dojo/_base/declare",
   "jimu/BaseFeatureAction",
   "jimu/WidgetManager",
   "esri/tasks/FeatureSet"
],    function(declare, BaseFeatureAction, WidgetManager, FeatureSet){
   var stuff = declare(BaseFeatureAction, {
      iconFormat: 'png',
      isFeatureSupported: function(featureSet){
      return featureSet.displayFieldName == 'SRVNAME'; //test feature for action validity
      },

   onExecute: function(featureSet){
      WidgetManager.getInstance().triggerWidgetOpen(this.widgetId)
      .then(function(myWidget){
/*=========== WIDGET ACTION ===========*/
         var twnshp = featureSet.features[0].attributes.TWNSHPLAB;
         var TS = twnshp[0] + twnshp[1];
         var RG = twnshp[4] + twnshp[5];
         myWidget.TSRecordsAction(twnshp,TS,RG);
      });

   }
});
return stuff;
});

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Stahly,

   I don't see anything wrong there. Not sure what to tell you...

0 Kudos