AnsweredAssumed Answered

I created a custom widget and I need create a queryTask to a table in the map. But I can not use new QueryTask. How I can do it?

Question asked by andreaCarina on May 29, 2017
Latest reply on May 30, 2017 by kenbuja

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;
});

Outcomes