Hi there, I was looking through the forum and couldn't find an exact solution to my problem.
I am using ArcGIS Pro and want to create a new sequential number every time a new point feature is created within my layer. I first want to sort OBJECTID by descending, which would give me the last CW_ID I used. I then want the new feature to have a CW_ID one higher than the last one used. How would I do this using arcade and attribute rules?
For example, if the last CW_ID after the OBJECTID sort was SAN6249, I want the new feature created to have a CW_ID of SAN6250 automatically. As a side note, each new CW_ID with start with SAN, so I am assuming there will have to be a split to isolate the integer and then a concatenation somewhere to recreate the string.
Please let me know if you need any more details.
Thanks!
Solved! Go to Solution.
The really easy way:
// Calculation Attribute Rule
// trigger: Insert
// field:CW_ID
var seq = NextSequenceValue("SequenceName")
return "SAN" + seq
If for some reason you can't create sequences, you'll have to do it the harder way:
// Calculation Attribute Rule
// trigger: Insert
// field:CW_ID
// get the latest feature with a CW_ID
var last_feature = First(OrderBy(Filter($featureset, "CW_ID IS NOT NULL"), "OBJECTID DESC"))
// get the last CW_ID and add 1
var seq = IIf(last_feature == null, 0, last_feature.CW_ID) + 1
return "SAN" + seq
The really easy way:
// Calculation Attribute Rule
// trigger: Insert
// field:CW_ID
var seq = NextSequenceValue("SequenceName")
return "SAN" + seq
If for some reason you can't create sequences, you'll have to do it the harder way:
// Calculation Attribute Rule
// trigger: Insert
// field:CW_ID
// get the latest feature with a CW_ID
var last_feature = First(OrderBy(Filter($featureset, "CW_ID IS NOT NULL"), "OBJECTID DESC"))
// get the last CW_ID and add 1
var seq = IIf(last_feature == null, 0, last_feature.CW_ID) + 1
return "SAN" + seq
Thanks so much!