Query all of a sudden stopped working

1431
1
06-11-2014 06:22 AM
DaveTaylor
New Contributor
This was working for over a week and now all of a sudden I am getting the following error:

Error {code: 400, message: "Failed to execute query.", details: Array[0], log: undefined, httpCode: 400???}

I am just calling a simple query...the query actually works and filters out the proper data but it never makes it inside my showResults function...the code is below including where it is failing:

var myQuery,
            myQueryTask;

        myQueryTask = new QueryTask(railLocationsURL + "/0");
        myQuery = new Query();
        myQuery.returnGeometry = true;
        myQuery.outFields = ["QUALIFICAT","NAME","GECFACILIT","CITY"];

        function execute() {
          var shopName = dojo.byId('shopName').value;
          myQuery.where = "NAME IN ('" + shopName + "')";    
          myQueryTask.execute(myQuery, showResults); 
    filter();    
        }

  //create symbol for selected features
      //  symbol = new SimpleMarkerSymbol();
      //  symbol.setStyle(SimpleMarkerSymbol.STYLE_SQUARE);
      //  symbol.setSize(10);
      //  symbol.setColor(new Color([255,255,0,0.5]));

  function filter(){
     var layerDefinitions = [];
     //var selectBusiness = dojo.byId('selectBusiness');
     //var selectCategory = dojo.byId('selectCategory');
     layerDefinitions[0] = myQuery.where;
     railLocationsLayer.setLayerDefinitions(layerDefinitions); 
     console.log(railLocationsLayer.layerDefinitions);
     console.log("after query");     
    }
//IT NEVER MAKES IT THIS FAR
  function showResults(featureSet) 
{  console.log("inside ShowResults"); 
    map.graphics.clear();
  
  var graphicsArray = [];
  var resultFeatures = featureSet.features;
  var railLocationTemplate = new InfoTemplate("Shop Location", 
        "<b>Shop Name: </b>${NAME}<br/>" + "<b>Address: </b>${ADDRESS1}<br/>" );
//featureSet.setInfoTemplate(railLocationTemplate);
    //Loop through each feature returned
 
for (var i=0, il=resultFeatures.length; i<il; i++) {
    var graphic = resultFeatures;
    graphic.setInfoTemplate(railLocationTemplate);
    graphicsArray.push(graphic);
  }
  
  var extent = calcGraphicsExtent(graphicsArray);
  
  map.setExtent(extent.expand(1), true).then(function(){            
    for(var i=0; i<graphicsArray.length; i++) {
      map.graphics.add(graphicsArray);
    }
  });
  }

  
function calcGraphicsExtent(graphicsArray)
{
    var g = graphicsArray[0].geometry,
    fullExt = g.getExtent(),
    ext, i, il = graphicsArray.length;

    if (fullExt === null) {
        fullExt = new Extent(g.x, g.y, g.x, g.y, g.spatialReference);
    }
    for (i=1; i<il; i++) {
        ext = (g = graphicsArray.geometry).getExtent();
        if (ext === null) {
            ext = new Extent(g.x, g.y, g.x, g.y, g.spatialReference);
        }
        fullExt = fullExt.union(ext);
    }
    return fullExt;
}
0 Kudos
1 Reply
williamcarr
Occasional Contributor II
Was anything modified in the past week? I've had difficulty in the past showing query results, but I have had some luck once I modified the parameters.You might want to try:


myQueryTask.execute(myQuery, showResults(featureset));
0 Kudos