AnsweredAssumed Answered

Field calculator python script and OBJECTID ordering issue

Question asked by cdd109 on Jul 14, 2015
Latest reply on Jul 14, 2015 by cdd109

Versioned SDE Geodatabase 10.2.2 / ArcMap 10.2.2 / Python27

 

 

 

I have a text field called FEATURE_UNIQUE_ID that consists of a 4 letter asset code and an increment number. I have added this field to several existing feature classes. To populate the field initially, I have a simple python script that I run in the field calculator (python codeblock) that assigns the value sequentially to the field. For example: WWTK101, WWTK102, Etc.

 

For the most part it works great. However, on some feature classes the number assignments start at an arbitrary value greater than that of the starting value assigned by the script. I cannot figure out why? I have tried editing as the data owner as well as geodatabase administrator. I have tried initializing rec to 100, to force the script to start at the value of 101. I have tried editing from the default version as well as running the script both before and after compressing / rebuilding indexes on those feature classes. I really need to figure out what is causing this issue, or I'm going to have to reorder these by hand -> not fun.

 

You will see in the screenshot below that in this particular feature class the numbering starts at 281 even though the OBJECTID starts at 1. The values are sequential, as in there are no values less than 281 in the column. they go from 281 up.

 

Any help is appreciated. please see below for screenshots and script code. Thanks.

 

Screenshot - 7_14_2015 , 2_47_59 PM.png

 

This code goes in the codeblock:

 

rec=0
strRec = ""
def autos():
 global rec, strRec
 pStart = 101
 pInterval = 1
 if (rec == 0):
  rec = pStart
 else:
  rec += pInterval
  strRec = "DRCB" + str(rec)
 return strRec

 

and the function autos() is called underneath. 90% of the feature classes I have used this on start numbering from 101 without issue.

Outcomes