Add an incremental, unique ID

10064
21
01-02-2020 09:21 AM
JoeBorgione
MVP Emeritus

This is a topic that's been around for as long as I can remember.  The attribute assistant provided a couple methods to do this: autonumber, generate id, and there us a tool called Add Incrementing ID field but it is limited to database tables, not GEOdatabase tables; if an object id is present, the tool won't work.

Is there a method or tool available in ArcGIS Pro 2.4.3 that will autoincrement a field in an enterprise geodatabase table and/or feature class?

That should just about do it....
Tags (1)
21 Replies
Robert_LeClair
Esri Notable Contributor

Joe - not sure the details of your workflow but there is a "Add Incrementing ID Field" GP tool that "may" work for you.  Have you seen/used this before?

JoeBorgione
MVP Emeritus

Robert-  for some reason the second half of my post didn't make the trip.  I looked at that tool, but it has limited application to a database table, not a GEOdatabase table.  If an object id already exists, the tool won't work...

That should just about do it....
0 Kudos
Robert_LeClair
Esri Notable Contributor

Yes, limited for sure.  I did look into the ObjectID issue you mentioned and the Help says "If you do not specify a name for the field, ObjectID is used by default. If a field named ObjectID already exists, the tool will not run until you provide a different name."  So you could create a new field for the unique values and then the GP tool would run.

JoeBorgione
MVP Emeritus

These are two lines in the help that pretty much torpedo my use of the tool:

This tool can only be used with database tables, not geodatabase tables.

If a database-maintained, incrementing ID field already exists in the table, this tool will not add another one.

My use case is when a record is added, I need to generate an incremental unique id; I could use a trigger on the back-end sql database, but I'd like to avoid that if at all possible.

That should just about do it....
0 Kudos
Robert_LeClair
Esri Notable Contributor

Yes, those 2 lines would definitely throw a monkey wrench in not being able to use the tool.  Just guessing here but I'm thinking a trigger on the back end might be the best approach.  I'd be curious to see if others reading this post have other ideas.

JoeBorgione
MVP Emeritus

There are some python calculator approaches you can find with dr google; here's one from esri but it just calcs a field for the entire feature class or table. 

That should just about do it....
JoeBorgione
MVP Emeritus

Taking a look at Attribute Rules.  The help states: 

To save time during editing, specific attribute values are automatically populated for newly created features. For example, when a new pole is created, the assetID attribute is generated based on a sequence.

That should just about do it....
JoeBorgione
MVP Emeritus

Just took a stab at Attribute Rules and it provides the solution I'm after.

  1. Set up sequence in gdb
  2. Add global ids to target table/feature class( attribute rules requirement)
  3. Add the attribute rule (see illustration below)

Attribute rules use Arcade so this rule will add the text SomePrefix along with the next number in the sequence.  I started the sequence at 100 an incremented by 1.  Once you have the run the add attribute rule tool, you are ready to make your edits....

That should just about do it....
by Anonymous User
Not applicable

This is exactly what I've been attempting to do. However, I'm using desktop. Thoughts?

0 Kudos