Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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 '13 at 10:23
up vote 0 down vote accepted

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

You can interrogate this via an AJAX request to and examine the fields response, which contains:


Note the type indicates it's the OID field.

share|improve this answer

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.

share|improve this answer

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

share|improve this answer

We're looking for long answers that provide some explanation and context. Don't just give a one-line answer; explain why your answer is right, ideally with citations. Answers that don't include explanations may be removed.

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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