Adding Sequential Values With the Attribute Rules in ArcGIS Pro
March 19, 2020

The Attribute Rules in ArcGIS Pro is a tool to set user-defined rules to improve and automate the data editing experience when using geodatabase datasets. In this example we will be working on adding sequential values to your geodatabase. What this process will do is add an ever increasing number in whichever field you choose as you edit and create new features. Using it will increase your data’s integrity and save you time in the process.

First off, assure that the feature you wish to add sequential values to has a Global-ID field in it. If not use the ‘Add Global IDs’ Geoprocessing tool.

 

GlobalIDs

 

Then you need to create a database sequence. Use the ‘Create Database Sequence’ Geoprocessing tool. Give it a Sequence Name that you will remember. In this case I just went with ‘Test’.

 

createdatabase

 

Finally, right click on the feature in the Contents panel. Go to Design and Attribute Rules.

 

AddRule

 

Make sure the top option is set to Calculation and hit Add Rule (Add Immediate Calculation Rule).  Give the rule a name, select which field you wish to use, check ‘Insert’ under Triggers, and enter this Python expression below.

 

if(isempty($feature.FID))

return concatenate(“P” + nextsequencevalue(“Test“));

 

Note that in this expression line: if(isempty($feature.FID)) you will want to change ‘FID’ to whatever the field name is you wish to add this to. Likewise, with this line: return concatenate(“P” + nextsequencevalue(“Test”)); the ‘Test’ must be named after the Database Sequence you made earlier. Mine was “Test”. You will also notice that in this line I have “P”  called out first in the Python Concatenate Module. What this will do is add a ‘P’ in front of each new sequence like so;

P1

P2

P3

P4

Feel free to add your own text or digits to go either in front or after your sequence or leave it out all together to have a standard number sequence. It all depends on what your project parameters require.

 

CodeStuff3 1

 

Hit Save.

 

Newly created features will now auto edit the next number sequence in your desired field. Please reach out to us if you have additional questions!

Events

Contact Frontier Precision

Frontier Precision Shop