Hi all!
I'm trying to query a related table, but I can't figure out what I am missing.
I have a feature layer (buildings) with a related table (contacts for the building), related through the UNIQUE_ID field (buildings) and the Bldg_ID3 field (contacts table) . When the building is clicked, the query is looking for a match in the OBJECTID field in the contacts table instead of a match in the Bldg_ID3 field (foreign key)
For example: clicked building has UNIQUE_ID = 254 --> query results in contact with OBJECTID = 254 instead of Bldg_ID3 = 254.
I double checked the relationship class in our SDE, and it's fine, it also works in a webbuilder map and ArcMap, but it doesn't work correctly in my javascript app.
What am I missing here??
Any help would be greatly appreciated.
map.on("click", function (event) {
queryMapClick = new Query();
queryMapClick.geometry = pointToExtent(map, event.mapPoint, 10);
var deferred = buildingLayer.selectFeatures(queryMapClick, FeatureLayer.SELECTION_NEW);
deferred.addCallback(function(result) {
console.log("result ", result[0]);
if (result.length > 0) {
dom.byId("bID").innerHTML = result[0].attributes.UNIQUE_ID;
dom.byId("bDescription").innerHTML = result[0].attributes.DESCRIPTIO;
dom.byId("bAddress").innerHTML = result[0].attributes.ADDRESS;
var relatedQuery = new RelationshipQuery();
relatedQuery.outFields = ["Bldg_ID3","Feature","Name","Phone1","Phone2","Email","int1"];
relatedQuery.relationshipId = 0;
relatedQuery.objectIds = [result[0].attributes.UNIQUE_ID];
// coded attempt.. query won't find any records
// relatedQuery.setDefinitionExpression = "Bldg_ID3 in (10)";
console.log("relatedQuery ", relatedQuery);
buildingLayer.queryRelatedFeatures(relatedQuery, function(relatedRecords) {
console.log("relatedRecords ", relatedRecords);
});
}
});
}); // end map.onThanks!
Marc