I've been unable to successfully complete a relationship query of my feature services using 1) the Get Related Records tool (aka Query Related Records Tool) in SL 3.2 Viewer and 2) using the SL API v3.2. My feature services run on ArcGIS Online hosted services account for developers. Note ESRI runs these ArcGIS Online subscription and developer accounts on ArcGIS Server v10.21.I believe the problem is that the query classes in the SL 3.2 API Tasks library cannot handle a new JSON syntax returned by the queryRelatedRecords REST operation on AGS v10.21.Here is a sample relationship query that successfully executes on an ESRI sample server service which ESRI happens to run on ArcGIS Server v10.0. queryTask = new QueryTask("http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/0");
queryTask.ExecuteRelationshipQueryCompleted += QueryTask_ExecuteRelationshipQueryCompleted;
//Relationship query
RelationshipParameter relationshipParameters = new RelationshipParameter()
{
ObjectIds = new int[] { 113880 },
OutFields = new string[] { "*" },
RelationshipId = 3,
ReturnGeometry = false
};
queryTask.ExecuteRelationshipQueryAsync(relationshipParameters);
void QueryTask_ExecuteRelationshipQueryCompleted(object sender, RelationshipEventArgs e)
{
RelationshipResult pr = e.Result;
if (pr.RelatedRecordsGroup.Count == 0)
{
//RelatedRecordsGroup.Count is always zero when query is executed on ArGIS Server 10.21
//But when executed against ArcGIS Server 10.0, RelatedRecordsGroup does contain the related records
}
else
{
foreach (var pair in pr.RelatedRecordsGroup)
{
//Do something
}
}
}
When I execute the same code on my feature service which runs on ArcGIS Online hosted feature services v10.21, the related records group count is always zero. Interestingly, no matter if I query the ESRI sample service or my own AGO account service, in Fiddler the REST queryRelatedRecords query is always valid AND the response DOES contain the related records. However, when I query my services on v10.21 the related records in the JSON response never make it into the ArcGIS Silverlight API query objects.I closely examine the requests and responses in Fiddler. When I query the sample service on ArcGIS Online v10.0, the JSON response format is:{"fields":[...],"relatedRecordGroups":[{"objectId":1,"relatedRecords":[...]}]}
However, when I query my feature service running on ArcGIS Online v10.21, the JSON response format is {"fields":[...],"relatedRecordGroups":[{"OBJECTID":1,"relatedRecords":[...]}]}
Notice the subtle difference in JSON syntax. From AGS v10.0 the related record group object is identified by the object ID attribute.In AGS v10.0 the object ID name is camel-cased: "objectId". However, in AGS v10.21 the object ID attribute is all-caps: "OBJECTID".I suspect the query classes in the ArcGIS Silverlight API v3.2 are case-sensitive to the JSON response. I think the query classes expect the relatedRecordGroups to be identified by the camel-case object ID attribute. At AGS 10.2 ESRI seems to have changed the same attribute to the all-caps "OBJECTID". According to my tests, the query classes are unable to de-serialize the related records in the JSON response presumably because the API expects the related records groups to be identified by a camel-cased object ID, rather than an all-caps object ID.This "bug" seems to make it impossible to use the ArcGIS SL API v3.2 to successfully complete a relationship query on AGS v10.21.