Select to view content in your preferred language

FeatureLayer.Attributes by field alias?

2998
0
09-14-2012 02:37 AM
ValentinFedulov
Occasional Contributor
I was trying to use the plugin example
Query Related Records Tool
and find out a bug. At least I think so.

With feature layer http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Petroleum/KSPetro/MapServer/1
this code wan't work
// Get the name of the ObjectID field.
objectID = relatesLayer.LayerInfo.ObjectIdField;
// get key value
Object v = inputFeature.Attributes[objectID]; // v is empty


but this code work just fine
// Get the name of the ObjectID field.
objectID = relatesLayer.LayerInfo.ObjectIdField;
string objectIDAlias = getFieldAlias(relatesLayer, objectID);
if(objectIDAlias != "") objectID = objectIDAlias; // because of bug? in Graphic.Attributes[fieldname];
// get key value
Object v = inputFeature.Attributes[objectID]; // v have id value

Because of feature layer has objectid field alias 'Object ID' and Attributes object give access to values by field alias.
I think, Attributes object must give access to values by field names.
0 Kudos
0 Replies