AnsweredAssumed Answered

query - return success or fail

Question asked by D.Orlando on Apr 22, 2016
Latest reply on Apr 22, 2016 by rscheitlin

curious how to return a Boolean within the lang.hitch environment.

 

I would like to :

call query and return true or false so I know to continue or not

I am currently using lang.hitch for the query's return function and just chaining my next query within that, I would like to call the second query from outside of this.

something like:

var pass = Query1();

if (pass) Query2

 

here is some code

// Step 1
getEvacGeom: function (area, status) { //, order, alert, recind) {
 var pass = false;
 var queryTask = new QueryTask(this.EvacLayer);
 var query = new Query();
 query.returnGeometry = true;
 query.outFields = ["*"];
 query.outSpatialReference = this.map.spatialReference;
 query.where = "AreaName = '" + area + "' and Status = '" + status + "'";
 queryTask.execute(query, lang.hitch(this, EvacGeom_returned), lang.hitch(this, EvacGeom_error));

 function EvacGeom_returned(results) {
  if (results.features.length > 0) {
   for (var i = 0; i < results.features.length; i++) {
    var feature = results.features[i];
    if (feature.attributes["EvacType"] == "Order")
     feature.setSymbol(symbolOrder);
    else if (feature.attributes["EvacType"] == "Alert")
     feature.setSymbol(symbolAlert);
    else if (feature.attributes["EvacType"] == "Recind")
     feature.setSymbol(symbolRecind);
    _glEvacs.add(feature);
   };
   // call Step 2 OLD WAY
   //this.getParcelsByEvacExtent(evacExtent);
   
   // NEW ATTEMPT
   pass = true;
   // ? return pass;
  }
 }
 function EvacGeom_error(e) {
  busyList.hide();
  alert(e.message)
 };
 return pass; // this just returns the original false......
},

Outcomes