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);
});
Solved! Go to Solution.
Errors?
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...
Have you done a console.log to see if getFieldDomain is returning a domain class?
const domain = San7Lyr.getFieldDomain("SUBTYPE", {feature: feat});
console.log(domain);
Ok So its giving me UNDEFINED after adding Console.log(domain);
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?
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...?
RAJ,
You have to use the same code on the returned results for that field:
domain.getName(feat.attributes.SUBTYPE);
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>