Coded Domain values when doing Query tasks

5195
38
Jump to solution
10-19-2018 07:50 AM
Rocky_
by
Occasional Contributor

Hello Friends, i saw lots of discussions on coded Domain values when doing Query tasks. But not a single is useful for me yet. I am having same question as you explain here. Can you please help me with the same for 4.9 API.

I am having 2 attributes with coded values..I want to add a drop down menu to selecting values for that specific attribute. So user can select specific value of that attribute and perform query task.

Right now am using below function.. 

Thank you.

let Status = new Query({
   returnGeometry: false,
   where: '1=1',
   returnDistinctValues: true,
   outFields: ['STATUS']
});
qTask1.execute(Status).then(function(results) {
      results.features.map(function(feat) {
      let opt5 = document.createElement('option');
      opt5.value = feat.attributes.STATUS;
      opt5.innerHTML = feat.attributes.STATUS;
      stadd.appendChild(opt5);
});
view.graphic.add(selectedGraphics);
});

 

let qSubtype = new Query({
   returnGeometry: false,
   where: '1=1',
   returnDistinctValues: true,
   outFields: ['SUBTYPE']
});
qTask72.execute(qSubtype).then(function(results) {
      results.features.map(function(feat) {
      let opt3 = document.createElement('option');
      opt3.value = feat.attributes.SUBTYPE;
      opt3.innerHTML = feat.attributes.SUBTYPE;
      subdd.appendChild(opt3);
});
view.graphic.add(selectedGraphics);
});

0 Kudos
38 Replies
RobertScheitlin__GISP
MVP Emeritus

Errors?

0 Kudos
Rocky_
by
Occasional Contributor

No Sir, its not giving any error in console.. Just the drop-down of the field("SUBTYPE") is empty.. All other functions and queries are working properly...

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Have you done a console.log to see if getFieldDomain is returning a domain class?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus
const domain = San7Lyr.getFieldDomain("SUBTYPE", {feature: feat});
console.log(domain);‍‍
0 Kudos
Rocky_
by
Occasional Contributor

Ok So its giving me UNDEFINED after adding Console.log(domain);

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

RAJ,

   If you look at the rest end point for your service it lists the domains for each field and types. Are you sure the subtype field has a domain?

0 Kudos
Rocky_
by
Occasional Contributor

Thanks a Lot Robert.. I think am trying to get domain values of wrong fields..

I just tried same one for other and it giving me all values..

THANKS A LOT TO HELP ME OUT..

But the now I have one more question, its giving me proper description of domain values..but when i perform query task it gives me coded integer values.. So how can i get that exact description in result table aslo...?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

RAJ,

   You have to use the same code on the returned results for that field:

domain.getName(feat.attributes.SUBTYPE);

0 Kudos
Rocky_
by
Occasional Contributor

So just i have to add only this line results

domain.getName(feat.attributes.SUBTYPE);

Thats it..

Got it..thanks

On Mon, Oct 22, 2018 at 11:55 AM Robert Scheitlin, GISP <geonet@esri.com>

0 Kudos