AnsweredAssumed Answered

Cannot get queryTask with query to return expected result

Question asked by mrogers83 on Jan 14, 2015
Latest reply on Jan 14, 2015 by rscheitlin

I am working with an existing website that I did most of the code on.  It is a Emergency Operations Center website with automatic vehicle tracking as well as history queries.  I was able to query the history for the vehicles with no problem, but I am now trying to query the history of the 911 calls and am coming across some issues.  Any help is greatly appreciated!

 

Here is the code I am working with:

window.Calls911HistoricalUrl = "http://gis10204:6080/arcgis/rest/services/GeoEvent/AVL_911_Historical_WebOut/FeatureServer/0";
window.Calls911HistoricalOutFields = ["PhoneNumber", "CallType", "TimeStamp"];

registry.byId("execute911bynumber").on("click", execute911bynumber);
  function execute911bynumber(){
  var queryTask = new QueryTask(window.Calls911HistoricalUrl);
  var query = new Query();
  query.returnGeometry = false;
  query.outFields = window.Calls911HistoricalOutFields;
  query.where = "PhoneNumber = " +"'"+number+"'";
  queryTask.execute(query, function(results) {
  var data = [];
  var data = array.map(results.features, function(feature) {
  return {
  //property names used here match those used when creating the dgrid                  
  "Phonenumber": feature.attributes[window.Calls911HistoricalOutFields[0]],                  
  "Calltype": feature.attributes[window.Calls911HistoricalOutFields[1]],
  "Timereceived": feature.attributes[window.Calls911HistoricalOutFields[2]]
  }
  });
  var memStore = new Memory({ data: data });
  //create historical data dgrid
  window.grid2 = new (declare([OnDemandGrid, Selection]))({
  bufferRows: Infinity,
  store:memStore,
  maxRowsPerPage: 5000,
  columns: {         
  "Phonenumber": "Phone Number",
  "Calltype": "Call Type",
  "Timereceived": {"label": "Time Received", "formatter": formatTimestamp}
  },
  loadingMessage: "Loading data...",
  noDataMessage: "No records found."
  }, "grid2");
  grid2.set("sort", [{attribute:"Timereceived", descending:true}]);
  });
  grid2.setStore();
  }

 

The html code is as follows:

 
  Phone Number:  
 
  Start Date & Time:  
 
  End Date & Time:  
 
       
 
     
 
 

I was able to search on date alone and come up with the correct information, but when I try and search on phone number alone, I am getting no results even though I know that there are at least 5 calls for that phone number.  I have also tried using query.text = dom.byId("number").value; but using that throws an error, "unable to complete operation".  Again, any help figuring this out is greatly appreciated.

 

Michelle

Outcomes