Summary
There is sometimes a business need to configure an ID in a feature class that starts at a certain number and increases by a pre-defined value in the database sequence. For a given project, the customer may not want to use object IDs and increment the same field by one. This article discusses how to define a unique ID and increment sequence in a feature class table.
Procedure
This workflow uses two geoprocessing tools to configure a database sequence that starts at and auto-increments with pre-defined values, and adds an attribute rule into a feature class or table using Arcade expressions to use this sequence in the desired field.
- Configure Database Sequence
- In ArcGIS Pro, search for the Data Management tool Create Database Sequence.
- In the Create Database Sequence geoprocessing tool, select the desired Enterprise Database in the Input Workspace, provide a name for the Sequence Name, a number for the Sequence Start ID, and the Sequence Increment Value
- Configure Attribute Rule
- Search for the Data Management tool Add Attribute Rule.
- In the Add Attribute Rule tool, provide a Name and Description for the rule
- Select Calculation for Type, the desired Feature Class or Table for Input Table, the Field for the sequence
- Uncheck Is Editable. This way, the sequence values are auto-generated and field workers cannot modify them since the values are coming from the database
- For Triggering Events, select Insert
- In the Script Expression, select the desired Field(s) and type: return "" + NextSequenceValue ('database_sequence_name')
We are now able to add features in the feature class or table that auto-populates the defined unique ID and increments by the value defined in the sequence.
Note:
If this feature class is published as a service and there are issues writing to this field in Portal for ArcGIS, ensure that the user who created the database sequence is the same as the owner of the table used in the attribute rule, and that this user has read and write privileges in the database.