AnsweredAssumed Answered

Filter Array

Question asked by jay.kapalczynski on Oct 21, 2015
Latest reply on Oct 22, 2015 by jay.kapalczynski

I have a query that:

  1. is selecting features via a Buffers Geometry
  2. It grabs that array, pushed to a Function and does a Unique filter on that array
  3. It then returns it to a table created via JavaScript.


I am not seeing a fully unique return you can see in the attachment there are two "sunfish, bluespotted" being returned even thought he COMMON_NAME field is the same as specified in the Unique Filter.


I am wondering if this is not working correctly?

do I have something set up wrong?


It is decreasing the number of returned records but does not seem to be getting all of unique values....I checked my data and this field seems to be unique, wondering if I am doing something wrong.




// SNIP.....


var query3 = new Query();

   query3.geometry = bufferGeometry;

  // Select the Points within the Buffer and show them

   featureLayerVAFWIS.selectFeatures(query3, FeatureLayer.SELECTION_NEW, function(results){


   // Query for the records with the given object IDs and populate the grid

   featureLayerVAFWIS.queryFeatures(query3, function (featureSet) {






function updateGrid3(featureSet) {

  var data =, function (entry, i) {

   return {

  id: entry.attributes.OBJECTID,

  ObsID: entry.attributes.ObsID,

  SppBova: entry.attributes.SppBova,

  COMMON_NAME: entry.attributes.COMMON_NAME,

  GENUS: entry.attributes.GENUS,

  SPECIES: entry.attributes.SPECIES,

  Tier: entry.attributes.Tier,

  FedStatus: entry.attributes.FedStatus,

  TaxaGrp: entry.attributes.TaxaGrp,




  var uniqueName = [];

  var UniquValues = array.filter(data, function (item) {

        var IsNameUnique = true;

       array.forEach(uniqueName, function (value) {

      if (value == (item.COMMON_NAME)) {

          IsNameUnique = false;



       if (IsNameUnique) {



       return IsNameUnique;



    var i;

    var out = "<table id=t01>";

    for(i = 0; i < uniqueName.length; i++) {

        out += "<tr><td>" +

        arr[i].id +

        "</td><td>" +

        arr[i].ObsID +

        "</td><td>" +

        arr[i].SppBova +

        "</td><td>" +

        arr[i].COMMON_NAME +

        "</td><td>" +

        arr[i].GENUS +

        "</td><td>" +

        arr[i].SPECIES +

        "</td><td>" +

        arr[i].Tier +

        "</td><td>" +

        arr[i].FedStatus +

        "</td><td>" +

        arr[i].TaxaGrp +



    out += "</table>";

    document.getElementById("id01").innerHTML = out;


  dom.byId('upload-function').innerHTML = "See Results below";

  domStyle.set(loadingShapefile, "display", "none");