I would like to know how to use 'AGSRelatedQueryParameters' with 'AGSRelationshipInfo'. Give me an example. I guess 'AGSRelatedQueryParameters' is the replacement for 'AGSRelationshipQuery'. Am i right?
Solved! Go to Solution.
You can find a sample here: arcgis-runtime-samples-ios/RelatedFeaturesViewController.swift
Hope that helps.
Nick.
You can find a sample here: arcgis-runtime-samples-ios/RelatedFeaturesViewController.swift
Hope that helps.
Nick.
Hi Nicholas Furness,
This returns an empty array. But the `AGSRelationshipInfo` logs the related table id correctly. FYI, i can get the related features in iOS Runtime SDK v 10.2.
AGSServiceFeatureTable * featureTable = (AGSServiceFeatureTable*)data.graphic.featureTable;
AGSRelationshipInfo * rInfo = featureTable.layerInfo.relationshipInfos.firstObject;
AGSRelatedQueryParameters * find = [AGSRelatedQueryParameters relatedQueryParametersWithRelationshipInfo:rInfo];
find.orderByFields = @[[[AGSOrderBy alloc] initWithFieldName:rInfo.keyField sortOrder:AGSSortOrderDescending]];
NSString * whereClause = [NSString stringWithFormat:@"""%@ = '%lld'""",rInfo.keyField,data.objectID];
[find setWhereClause:whereClause];
[featureTable queryRelatedFeaturesForFeature😞AGSArcGISFeature*)data.graphic parameters:find completion:^(NSArray<AGSRelatedFeatureQueryResult *> * _Nullable results, NSError * _Nullable error) {
if(error)
{
}
else
{
NSLog(@"result-assets :: %@",results);
}
}];
Did i missed any thing here?
Regards,
Hi,
Depending on what data.graphic is, you may need an additional step.
If data.graphic is an AGSArcGISFeature instance which you created, added, and then stored with applyEdits (as opposed to an object you got back from a query), then before you do further operations on it, you should call AGSArcGISFeature.refreshObjectID().
In more detail: For any feature you get with a query, it'll already have the data store's ID populated, but if you create the feature, there is no ID until it's stored (when working against a local geodatabse/shapefile, that happens when you call addFeature, or when working against an AGSServiceFeatureTable, when you call applyEdits). Since it's bad for us to assume we can update your Objective-C objects without telling you, we don't set the ID automatically as part of the add/apply operation, so if you want to continue using the same reference to the AGSArcGISFeature for future writes (e.g adding attachments or relating records), call AGSArcGISFeature.refreshObjectID().
In your case above, try calling refreshObjectID() on data.graphic before querying for related features.
Let me know if that helps.
Nick.
Yes, your reply worked for me. This is regarding listing related features. I have followed the following class arcgis-runtime-samples-ios/ListRelatedFeaturesVC.swift at ea83939a56101ef82f17ff6eecb1b2faa716d720 ·... to fetch the related features. I tried to add related table in mapview as like in example. i got the following error:
ArcGIS Runtime Error Ocurred. Set a breakpoint on C++ exceptions to see the original callstack and context for this error: Error Domain=com.esri.arcgis.runtime.error Code=24 "Object already owned." UserInfo={NSLocalizedFailureReason=Already owned., NSLocalizedDescription=Object already owned., Additional Message=Already owned.}
I didn't get any clear idea about this. How can i add related table object to map.tables.
It's really hard to determine without more info or sample code, but in general that error means that something else is already tied to that table. The table may already be part of the map.tables collection or a layer in your map might be using it.
If you still really need to duplicate the layer, you could call copy() on it and add that reference to the map but I'd suggest you double-check that you're not unwittingly duplicating things.