Select to view content in your preferred language

Query a layer based on a relationship

2181
3
Jump to solution
12-30-2013 11:28 PM
raffia
by
Deactivated User
Hi all, Happy New Year. I hope I caught everyone in the best of moods.

So we have created a new advanced DB with relationships. We have a landmarks point layer (http://arcgis4.roktech.net/arcgis/rest/services/DigitalEgypt/EGIPA_NewCairo/MapServer/2), and a LandmarkTypes (http://arcgis4.roktech.net/arcgis/rest/services/DigitalEgypt/EGIPA_NewCairo/MapServer/17) table that defines the types, and both are connected with this table (http://arcgis4.roktech.net/arcgis/rest/services/DigitalEgypt/EGIPA_NewCairo/MapServer/22). What I am trying to do is a query to return all landmarks that are of a specific type (LandmarkTypes_ID=106). Each landmark has a couple of more relationships, if just one of those can return with the query results, would be a fantastic start for 2014 🙂

I looked at the samples available, the ones about the relationship don't do what we are trying to do. Is there maybe a sample somewhere that will illustrate this?

Thanks;
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
MikeDahm
Frequent Contributor
Have your tried looking at the queryRelatedFeatures function within the featurelayer or the RelationshipQuery?

https://developers.arcgis.com/en/flex/api-reference/index.html?com/esri/ags/layers/FeatureLayer.html...

https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/tasks/supportClasses/RelationshipQu...

The most helpful to me was to use the code from the Multiple related records example for relationship query:

https://developers.arcgis.com/en/flex/sample-code/multiple-related-records.htm

Look at how the relationship query is in the declarations and read more about it in the API reference to limit the fields etc.  The fieldsLayer_selectionCompleteHandler function has all of the code you will need to perform the relationship query, you will have to modify it to your layers and fields.  It provides the code for doing the quesry and creating the onResult and onFault coding.

Otherwise you could run a query on the related table and create an array of the selected feature id's and then use that to select the features within your landmark layer.

View solution in original post

0 Kudos
3 Replies
raffia
by
Deactivated User
In case if anyone is wondering, we are still accepting answers 🙂
0 Kudos
MikeDahm
Frequent Contributor
Have your tried looking at the queryRelatedFeatures function within the featurelayer or the RelationshipQuery?

https://developers.arcgis.com/en/flex/api-reference/index.html?com/esri/ags/layers/FeatureLayer.html...

https://developers.arcgis.com/en/flex/api-reference/com/esri/ags/tasks/supportClasses/RelationshipQu...

The most helpful to me was to use the code from the Multiple related records example for relationship query:

https://developers.arcgis.com/en/flex/sample-code/multiple-related-records.htm

Look at how the relationship query is in the declarations and read more about it in the API reference to limit the fields etc.  The fieldsLayer_selectionCompleteHandler function has all of the code you will need to perform the relationship query, you will have to modify it to your layers and fields.  It provides the code for doing the quesry and creating the onResult and onFault coding.

Otherwise you could run a query on the related table and create an array of the selected feature id's and then use that to select the features within your landmark layer.
0 Kudos
raffia
by
Deactivated User
Thank you Mike, using those links and a post in the forums I figured it all out.
Raffi
0 Kudos