Search code examples
javascriptdojoesri

esri QueryTask not returning results


I am trying to return the geometry of a given feature based on queries. It works for some of the features, but for the rest, it returns null. Any one have any idea what might be wrong with my code? I do appreciate your answers in advance...

    var advQueryTask = new QueryTask(finQuerURL);
    advQueryTask.disableClientCaching = true;
    var advQuery = new Query();
    if (typeof curMapLyr.layerDefinitions[curLayerID] === 'undefined') {
     advQuery.where = whrCls;
            } 
    else {
           advQuery.where = curMapLyr.layerDefinitions[curLayerID] + ' and (' + whrCls + ')';
            }
    console.log(advQuery);
    advQuery.outFields = retCols;
    advQuery.geometry= map.extent;
    advQuery.returnGeometry = true;
    advQueryTask.useAMF = false;
    advQuery.outSpatialReference = map.spatialReference;
    //  advQuery.outFields = ["*"]; 
    advQueryTask.execute(advQuery, showAdvQueryRes);
        } 
    else {
            alert('Please select a column to search by.');
        }
    });
}

    function showAdvQueryRes(res) {
     ++selectionCntr;
     var curSelectNum = selectionCntr;
     dynamicIDs['select_' + curSelectNum] = res;
     if (res.features.length > 0) {
        addResults(curSvcID, curLayerID, curSelectNum);
    } 
    else {
        alert('No results were found. Please try again.');
    }
    hideLoading();
}

Solution

  • If anyone's experiencing same issue, I got the answer. I had to go to the mxd file through the features and enable the shape field in them (they can be opened by Arc map)!