define([
'dojo/_base/declare',
'jimu/BaseFeatureAction',
'jimu/WidgetManager',
'esri/tasks/query',
'esri/tasks/QueryTask'
], function(declare, BaseFeatureAction, WidgetManager){
var clazz = declare(BaseFeatureAction, {
iconFormat: 'png',
isFeatureSupported: function(featureSet){
return featureSet.features.length == 1 && featureSet.features[0].attributes.state_name != undefined && featureSet.features[0].attributes.state_name == 'Montana';
},
onExecute: function(featureSet){
WidgetManager.getInstance().triggerWidgetOpen(this.widgetId)
.then(function(myWidget) {
var queryTask = new QueryTask("http://services2.arcgis.com/zjX47EEgMzOqxwh7/ArcGIS/rest/services/Mapa/FeatureServer/1");
var query = new Query();
query.returnGeometry = false;
query.outFields = [
"Bocas"
];
query.text = "EquipoId = 'Eq1'";
queryTask.execute(query, showResults);
function showResults(results) {
var resultItems = [];
var resultCount = results.features.length;
}
myWidget.ViewImage(resultCount);
});
}
});
return clazz;
});
You have to add in the arguments in the function to tell the code what QueryTask and Query are. If you examine the console, you should see errors indicating this.