I am using query task to do a attribute query for features with a where clause. I have verified that the specific layer I am querying has the field LK_ID_NUM
.
My query task do not return an error, but no features are found. Therefore the results.features returns undefined. I checked the where condition (LK_ID_NUM = 46014
) directly on the ArcGIS Rest service and the query returns a feature successfully. I tried the query without the where clause, and it still did not return any features, only the feature layer information is returned.
I Thought the issue is that i require a geometry input to the query. I tried added a extent geometry and changed the spatial relationship to "Contains". But this did not solve the issue. There is still no features returned.
My JS query code is shown below.
task.featureLayer = layer;
task.queryTask = new QueryTask( this.validateUrlToken.addTokenIfApplicable( layerUrl ) );
task.query = new Query();
task.query.outFields = [
"*"
];
task.query.returnGeometry = true;
task.query.outSpatialReference = this.map.map.spatialReference;
var whereclause = "LK_ID_NUM = " + gislink ;
task.query.where = whereclause; //only query features that has same LinkID
console.log("query condition: ", whereclause);
tasks.push( task );
console.log("Query Tasks captured: ",task);
var defferedTask = task.queryTask.execute( task.query );
this.aDeferreds.push( defferedTask );
promises = all( this.aDeferreds );
promises.then( lang.hitch( this, this.handlelinkResults ), lang.hitch( this, function ( err ) {
console.error( 'query error', err );
this.map.hideLoadingImg();
this.stopTimeout = true;
if ( this.errorType == null ) {
var errorMessage;
if ( err.message ) {
errorMessage = err.message;
console.log(errorMessage);
} else {
errorMessage = err;
console.log(errorMessage);
}
}
} ) );
handlelinkResults: function(r) {
//console.log("Check if handle link results function is used");
var features = [];
var featuresValue = [];
var featuresLayersIds = [];
var featuresCountForFeaturesLayers = 0;
var featuresCountForDynamicLayers = 0;
//console.log("Debug what is r:", r);
array.forEach(r,function(result,j){
console.log("debug results:", result);
console.log(result.features);
var resultfeat = result.features;
if ( resultfeat && resultfeat.length > 0) {
array.forEach( resultfeat, function ( feat, j ) {
console.log(feat);
var value = feat.value + "_" + feat.layerId;
var layerNameId = this.featureLayersNameId[ this.layersRequest[ j ] ];
feat.attributes.layerName = layerNameId.layerName;
feat.attributes.layerId = layerNameId.layerId;
feat.urlLayer = this.layersQueryTask[featuresCountForDynamicLayers].url + "/" + layerId;
feat.layerInfos = this.layersQueryTask[featuresCountForDynamicLayers].layerInfos;
feat.layer = this.layersQueryTask[featuresCountForDynamicLayers];
feat.layer = this.layersQueryTask[featuresCountForDynamicLayers];
features.push( feat );
}, this );}
},this)}
I included the screenshots below. The first image is the query that I constructed and logged in console for debugging. The second image is the returned results. I do not see any feature element in the result for my query.
Where did I go wrong?