AnsweredAssumed Answered

How to store multiple featureLayer.queryFeatures results in  an array or object

Question asked by schlot on Sep 4, 2014
Latest reply on Sep 4, 2014 by schlot

I have a queryFeatures on a featureLayer that is based on mutiple objectIds. I need to iterate through each feature and store attributes in an array.  I need to keep each feature's array in another array (or maybe an object?) so I can have it as input to my chart.

gQuery = new Query();
  gQuery.objectIds = idList;  //defined earlier
seriesList.length = 0;  //declared earlier as seriesList = [];
 featureLayer.queryFeatures(gQuery, function(results) {
    arrayUtils.forEach(results.features, function (result){
      var list = createRateList(result);
console.log("list is " + list);
          seriesList.push({data: list});

function createRateList(results){
  var atts = results.attributes;
  var county = atts.County;
  rateList.length = 0;
  reverseRateFields.length = 0;
  //gets the rate values for selected county for all years, list of field defined earlier
      arrayUtils.forEach(reverseRateFields, function (field){
    return rateList;

At the point I have do a console.log on list, it contains the values I expect.  I add it to my seriesList and it still looked OK.   Going to the next feature, I the console.log display what I expect from the list, but what I push to seriesList affects what's already in there.  Examining the contents of seriesList shows the initial item [0] with content I just added from the 2nd time through.  This continues through how ever many features I had from queryFeatures until I have a seriesList full of the exact same list of values, which are from the final feature.


I don't know if I have a looping problem, or don't understand the nature of array variables.