Select to view content in your preferred language

How to handle query results from multiple fields

1079
6
Jump to solution
07-09-2014 03:01 PM
MatthewBaker2
Occasional Contributor II

Hi all,

With thanks to John Gravois, I've been able to pass geometry from the result of a geocoder, along with a field name, to a spatial intersection query to run against a school boundary layer.

What I'd like to do is pull the school boundary number from the corresponding field the user chooses - that is - the user chooses Grade 6 from the drop down, which means I want the value from the SCHOOL_6 field in the boundary layer I'm querying.

So I'm wondering how I should do this:

1) Do I use the SCHOOL_6 value in the outfields query parameter and pull that value, which yields this result:

singleFieldResult.PNG

additionally - how do I pull that value 416 if there is only ever 1 feature returned, but the field name could always change based on the drop-down?

or ...

2) Pull all the fields from the query layer, and select the attribute from the field that matches the value of the drop-down (ie. SCHOOL_6), and sift through the results that way. Here's what the results look like from pulling all the fields:

multipleFieldResults.PNG

@

The purpose of pulling this boundary number is that it will go into the last query, which will pull all the schools belonging to that boundary number.

UPDATE: I have added the code I am working on. cc Jake Skinner

Any thoughts appreciated.

Message was edited by: Matthew Baker

0 Kudos
1 Solution

Accepted Solutions
JohnGravois
Frequent Contributor

you can retrieve values from a known field a couple different ways...

attributes.FIELDNAME

attributes["FIELDNAME"]

the second syntax would be better for you if you want to substitute a variable.

View solution in original post

6 Replies
JakeSkinner
Esri Esteemed Contributor

Hi Matthew,

It may be helpful to post the code you are working with.

0 Kudos
MatthewBaker2
Occasional Contributor II

Jake Skinner‌, added the code I'm working with.

0 Kudos
JakeSkinner
Esri Esteemed Contributor

Try the following:

qt.execute(queryBounds, function(results) {    

    var resultBound;

    resultBound = results.features[0].attributes;

    console.log(resultBound);

});

JohnGravois
Frequent Contributor

you can retrieve values from a known field a couple different ways...

attributes.FIELDNAME

attributes["FIELDNAME"]

the second syntax would be better for you if you want to substitute a variable.

MatthewBaker2
Occasional Contributor II

JGravois-esristaff‌ perfecto! That works great and will let me do exactly what I need - substitute the variable from the drop-down to the result specific to the corresponding field... great stuff!!! Many thanks to both of you! cc jskinner-esristaff

0 Kudos
JohnGravois
Frequent Contributor

anytime amigo.

0 Kudos