I know that this is probably a very basic programming but I am brand new to Python.
I have a layer in a geodatabase that I need a unique ID field (for joining). I can't use the ObjectID because that can change. I can't use a GlobalID because the data will be used by databases that can't handle the "{" brackets or dashes.
I have already populated the field. When I add a new feature I want to have the value of the max existing value + 1 for the new feature.
Thanks to Jason here is what I have so far-
import arcpy
gdb_full_path = r'D:\GIS\ZA.gdb\Current'
feat = 'ZA_Merge'
arcpy.env.workspace = gdb_full_path
with arcpy.da.SearchCursor(feat,["ANID"]) as cursor:
for row in cursor:
unique_id_counter = row.count
with arcpy.da.InsertCursor(feat,["ANID"]) as cursor:
cursor.insertRow((unique_id_counter + 1))
Here is the error that I get -
Runtime error Traceback (most recent call last): File "", line 9, in TypeError: unsupported operand type(s) for +: 'builtin_function_or_method' and 'int'