Select to view content in your preferred language

How to automate an ID (Guid or sequence) without using the ArcMap Calculate Field

5654
6
09-06-2013 04:42 AM
NathalieLambert
Occasional Contributor
I found many exemples on how to calculate a field that contain an ID (sequence or GUID), but it was always with the field calculator, which means that it is calculed on time for all records.

What I'd like to do is, that everytime we create a new record, the ID field is automatically calculated.

Any Idea on how to do it ? Do I need to do a class extension ?

Thank you,

Nathalie
6 Replies
DuncanHornby
MVP Notable Contributor
I'm guessing you need your developer to create an extension that listens out for "on create of Feature" events. Look at the IEditEvents interface. This has an event handler that captures the on create of feature event which you could insert code to generate an ID in your field.

Duncan
0 Kudos
ForrestJones
Esri Contributor
You could maybe use a globalid (a guid maintained by the geodatabase) or a trigger in the database if using sde...

Some info from the help:

ArcGIS field data types

Inserting a value into a global ID or GUID column in SQL Server using SQL
0 Kudos
ThomasColson
MVP Frequent Contributor
If you're using an enterprise geodatabase, e.g. MS SQL, you could set the field type to uniqueidentifier, and default it to newid() or newsequentialid(). THen write an instead of insert trigger, including ALL columns EXCEPT for the GUID column.
0 Kudos
NathalieLambert
Occasional Contributor
In fact, I'm using ArcSDE with an Oracle Database (ArcGIS 10.0).

I first used a GloablID, because it allows me to create a unique ID, but then  I read, that I cannot import a GlobalID in an other table; this is why a change my mind about GlobalID.

If I use a field of GUID Type, it is not automatically calculed. I can only calculated it with the field Calculator.

I'd love to use a trigger to calculated my ID, but I don't know how I can create a trigger in an ArcSDE database.

Thank you,

Nathalie
0 Kudos
MichaelRobb
Honored Contributor

Hi Nathalie, 

I know this is an old posting but I want to help others that may come across this... 

There are many ways to copy and load records into a new table in a new geodatabase and preserve GlobalID Values.  

1. When copying data in ArcGIS, copy and paste, data extraction and XML workspace import preserves the GlobalID Values.

2. ArcObjects:  on an unversioned SDE Geodatabase, you can convert the gloablID to a GUID field... then import the data... then convert the GUID back to the GloablID field.

3. ArcObjects: on an unversioned SDE Geodatabase...Using DataChangesImporter to monitor delta and preserve GlobalIDs.

4. In ArcGIS Pro:  Preserve GlobalIDs. - Python

 ref:  Preserve Global IDs (Environment setting)—Geoprocessing | ArcGIS for Desktop 

0 Kudos
MitchHolley1
MVP Regular Contributor

You can do it in Python with the UUID module.  See here: UUID objects — Python 2.7.12 documentation 

0 Kudos