I need to get the primary key column of the Particular layer added in the Map. Usually 'FID' be found for a Shapefile Layer Source and OBJECTID found for a SDE source layer.

Is there any way to Identify which one is the primary key columns so that I can access those values.

I need to get this using ArcGIS JS API Version.3.3 and I am using ArcGIS Server 10.

  • You can use "ObejectID".. I am using ObjectID column to display the attribute information of feature. For details please check ArcGIS Java Script API 3.3 samples
    – Sunil
    Feb 5, 2013 at 10:23

3 Answers 3


You could handle this using esri.request, or directly perform an AJAX request. Either way, you want to hit the layer's ArcGIS Server REST API.

Eg take the sample layer http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2

You can interrogate this via an AJAX request to http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer/2?f=json and examine the fields response, which contains:


Note the type indicates it's the OID field.


You could check it with Python...

import arcpy

layer= r"Put here the path to your data"
dscfc = arcpy.Describe(layer)

if dscfc.hasOID == True:
    print dscfc.OIDFieldName
    print "No Primary Key found."

The OIDFieldName is the PK for the table.


You could loop through the fields for each layer and find the Object ID data type.

  • Is there any example, or link to documentation you could provide?
    – nagytech
    May 29, 2015 at 2:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.