QueryTask and coded domain values

7922
13
Jump to solution
02-25-2015 02:50 PM
WilliamMeredith
New Contributor

Is it possible to return coded domain values using QueryTask in the JavaScript API?  FindTask seems to do it ok, no luck with QueryTask.

Tags (1)
0 Kudos
13 Replies
RobertScheitlin__GISP
MVP Emeritus

Roxanne,

  If is going to be a definite learning curve for you as I can see you don't even understand the basics of writing a function. You really need to do some Googling on JS Basics.

JavaScript 101, Beginner's Guide to Learning Block / Inline JavaScript

The function you are attempting should look like:

function getMake(Make){

  if (Make === 1){

  return "Axis";

} else if (Make === 2){

  return "Vicon";

};

}

0 Kudos
RoxanneWilson
New Contributor III

I've got zero experience with coding or javascript.  So to say this project has been a bit of a learning curve, is a bit of an understatement.

I appreciate you correcting the issue with my function code.  Just one last question.  With another function that is in the template, the function was create like:

SetImage = function (value, key, data), etc...

Then in the popup I was able to reference the SetImage function to display an image instead of the file value.  When I put the getMake function in the popup, it doesn't return the values Axis or Vicon.  Is that because the getMake function doesn't have the =  ?  And since it doesn't, am I still able to reference that function so it shows Vicon or Axis in the popup instead of 1 or 2?

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Roxanne,

  Correct, it would have to be:

var getMake = function(Make){

  if (Make === 1){

  return "Axis";

} else if (Make === 2){

  return "Vicon";

};

}

0 Kudos
ahmed_hussiney
New Contributor III

Another way to do this , in the query task result you can find the field information including domain information if the field is assigned to domian, Then you can get each coded domain value and update the query result with domain instead of the code.

var domain = queryResults.featureSet.fields["Your Field Index"].domain;

var codedValues = domain.codedValues;

0 Kudos