In Desktop's old Attribute Assistant, you could create a generate ID rule that could keep a consistent width to the integer portion of the ID. So you could have a width of 7 and if the sequence was only 3 numbers, it would add 4 zeros to the left.
I'm trying to migrate a client from Attribute Assistant to Attribute Rules in Pro and I cannot find a way to accomplish this same functionality. In the screenshot you can see how their IDs generated in ArcMap/Attribute-Assistant vs. how I can get them to generate in Pro using the following:
return "ADA-" + NextSequenceValue ("ADA")
where I've named the generated sequence "ADA"
What arcade can I add in to that expression to maintain that forced width?
Solved! Go to Solution.
Haha, I didn't even think of the Text() function...
Disregard the above, use this instead:
return "ADA-" + Text(NextSequenceValue("ADA"), "0000000")
Hi @Anonymous User ,
In ArcGIS Pro, click on the feature class layer you want to add attribute rules to in TOC and then click Data tab > Attribute Rules in Design.
In Attribute Roles windows you can add a Calculation Rule in Arcade like:
concatenate('ADA-000',$feature.<your fc field>)
I hope that helps.
Cheers
Mehdi
======================================================================
Please give a like if helpful and Accept as Solution if it's answered your query.
@Anonymous User ,
Then you need to use something similar to this:
var ADA_id = split($feature.<your ADA field>, "-")[1]
If (Count(ADA_id ) == 4) {
return concatenate('ADA-000',ADA_id)
}
else {
If (Count(ADA_id ) == 3) {
return concatenate('ADA-0000',ADA_id)
}
else {
return ADA_id
}}
======================================================================
Please give a like if helpful and Accept as Solution if it's answered your query.
// next sequence value as string
var ada = "" + NextSequenceValue("ADA")
// there doesn't seem to be a while loop in Arcade,
// but we can fake one with a for loop...
for(var i = 0; i < 100; i++) {
if(Count(ada) >= 7) {
break
}
ada = "0" + ada
}
return "ADA-" + ada
Haha, I didn't even think of the Text() function...
Disregard the above, use this instead:
return "ADA-" + Text(NextSequenceValue("ADA"), "0000000")
This worked perfectly! Thank you!