queryIds method return obj

577
1
10-01-2013 02:02 PM
BrianBehling
New Contributor III
The API docs say the queryIds method returns a list of ObjectIDs. Is that a typo, or does the method really return a list of ObjectIDs?

If the docs are truly correct, why on earth would we ever want to get a result of ObjectIDs? What we would want returned is a FeatureSet.

Can anyone verify if this is correct or not?

https://developers.arcgis.com/en/javascript/jsapi/featurelayer-amd.html#queryids
0 Kudos
1 Reply
JasonZou
Occasional Contributor III
What the doc says is correct. It is useful when you need to query the related records for some features, but no need to get those feature details. Here is the code snippet from ESRI document. Consider to replace [graphicAttributes.OBJECTID] in relatedQuery.objectIds = [graphicAttributes.OBJECTID]; with the objectIds returned from the queryIds method call.

require([
  "esri/layers/FeatureLayer", "esri/tasks/RelationshipQuery", "dojo/_base/connect", ... 
], function(FeatureLayer, RelationshipQuery, connect, ... ) {
  var featureLayer = new FeatureLayer( ... );
  var relatedQuery = new RelationshipQuery();
  relatedQuery.outFields = ["AGREE_WITH_INCIDENT"];
  relatedQuery.relationshipId = 1;
  
  //query for the features related to the "clicked" feature
  connect.connect(featureLayer, "onClick", function(evt) {
    graphicAttributes = evt.graphic.attributes;
    relatedQuery.objectIds = [graphicAttributes.OBJECTID];
    featureLayer.queryRelatedFeatures(relatedQuery,relatedRecords);
  }
  ...
});
0 Kudos