I've got a python script that runs on the Field Calculator of a ESRI File Database. Right now it runs correctly in that it will increment the last three digits of the value. But this is a script that is run as part of post processing so it will be run everytime there are new entries in the feature class. My question is how can I modify this so that every time it runs it will look at the last four digits of the FacilityID and increment from there below is a screenshot of my attribute table:
EDIT: And below is my Python script I need to modify.
cur = arcpy.SearchCursor("Telecommunications Line") fac_id_values = [int(row.FACILITYID[-4:]) for row in cur] maximum_value = max(fac_id_values) if maximum_value: rec= maximum_value else: rec = 0 def autoIncrement(): global rec pStart = 1 pInterval = 1 if (rec == 0): rec = pStart else: rec += pInterval return "COMLI" + "11" + format(rec, '03d')
Ok after running the code above I got this as a result. It overwrote the previous values as shown above. The First item should have a FacilityID of COMLI111001.