Reputation: 1
I am having trouble with the ESRI ArcGIS Javascript API RelationshipQuery class.
I am trying to grab field(s) from a different GIS layer (in this case layer 1) in my GIS Service using the RelationshipQuery class. In other words, I want grab records with the same SCTM field in layer 1 as the SCTM field in the assessorLayer FeatureLayer object for the clicked point so I can populate all of the information into ONE pop-up window.
This is my code segment regarding the RelationshipQuery class
var title, content, graphicAttributes;
var relatedQuery = new RelationshipQuery();
relatedQuery.relationshipId = 1;
relatedQuery.outFields = ["*"];
assessorLayer.on("click", function(evt)
{ /* start assessorLayer.on click event */
graphicAttributes = evt.graphic.attributes;
title = "Assessor";
content = "<b>Name: </b>" + graphicAttributes.OWNER_NAME + graphicAttributes.OWNER_NAME2
+ "<br><b>Dimensions: </b>" + graphicAttributes.DIMENSIONS
+ "<br><b>Garbage District: </b>" + graphicAttributes.CBA;
relatedQuery.definitionExpression = ("SCTM = " + graphicAttributes.SCTM);
assessorLayer.queryRelatedFeatures(relatedQuery, function(relatedRecords)
{ /* start assessorLayer.queryRelatedFeatures function */
var status = relatedRecords[graphicAttributes.STATUS];
content = content + "<br><hr><br> Status: " + status;
map.infoWindow.setTitle(title);
map.infoWindow.setContent(content);
map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));*/
}); /* End assessorLayer.queryRelatedFeatures function */
}); /* End assessorLayer.on click event */
Upvotes: 0
Views: 611
Reputation: 331
You need top set the objectid for the relationship query, so in the assessorLayer.on("click", function(evt) handler you can add
relatedQuery.objectIds = [evt.features[0].attributes.OBJECTID];
Another option is to use the popup template related fields syntax so that the popup automatically queries the related table for the feature and populates itself accordingly. The JS API documentation has examples of this
Upvotes: 1