AnsweredAssumed Answered

JS API 4.16 Coded Domain Values with QueryTask

Question asked by luckachi on Aug 18, 2020
Latest reply on Aug 25, 2020 by ajbooter

There are a lot of threads that talk about returning the coded domain values descriptions while using a queryTask but from the few examples I have seen using the 4.x API, I can't get anything to work. My code is below if anyone could help me. I haven't really found any examples along the same lines as to what I am trying to do.

 

//build query task
    var queryTask = new QueryTask({
      url: "https://services.arcgis.com/uHAHKfH1Z5ye1Oe0/arcgis/rest/services/misin_treatments_aquatic/FeatureServer/0"
      });

    //build query filter
    var query = new Query();
    query.returnGeometry = true;
    query.outSpatialReference = view.spatialReference; //added for testing
    query.outFields = ["*"];


    //pass the url parameters.
    var urlObject = urlUtils.urlToObject(window.location.href);
    if (urlObject.query)
    {
      if (urlObject.query.id)
      { OID = urlObject.query.id; }

    //set query based on the parameters

    var treatmentid = "OBJECTID = '" + OID + "'";
    query.where = treatmentid;
    }

  // execute query, place graphic on map and zoom to graphic
      queryTask.execute(query).then(function(result){
         console.log(result.features);
         view.graphics.removeAll();
         view.popup.close();

         var resultFeatures = result.features;
         resultFeatures.map(function(gra){
           gra.symbol = sym;
           view.graphics.add(gra);
           gra.popupTemplate = popupTemplate;

           // Provide graphic to a new instance of a Feature widget
         const feature = new Feature({
           container: "attributes",
           graphic: gra,
           map: view.map,
           spatialReference: view.spatialReference
         });

         var AOI = result.features;
         view.goTo(AOI);
       });
     });

Outcomes