Leading Zeros for Facility ID in Feature Class using Attribute Rules and Arcade

2370
5
Jump to solution
03-03-2021 01:54 PM
Labels (2)
GISUSER6
New Contributor III

Hello,

I am trying to generate Facility IDs for my Water Meter feature class in ArcGIS Pro using Attribute Rules. This is the code I have so far, but I need to figure out how to add leading zeros, or decimal places to the ID. What I come up with is "wMET3" and I would like "wMET003".  Any insight would be greatly appreciated. 

AnnaPeters_0-1614808376018.png

if(isempty($feature.FACILITYID)) return concatenate("wMET" + nextsequencevalue("wMeterSeq"));

 

 

 

0 Kudos
1 Solution

Accepted Solutions
LanceCole
MVP Regular Contributor

I have not worked with this in Pro Attribute Rules but the Concatenate function in Arcade is Concatenate( values, separator?, format? ).  Try using the following in your return:

 

Concatenate(['wMET', nextsequencevalue("wMeterSeq")], '', '000')

 

 

 

 

View solution in original post

5 Replies
jcarlson
MVP Esteemed Contributor

Put your sequence value into the Text function. In the format parameter, a '0' is a mandatory digit, which will appear as a leading zero if the sequence is not that high yet.

 

var seq_num = 3

return 'Meter' + Text(seq_num, '0000')

 

Returns:

'Meter0003'

 

- Josh Carlson
Kendall County GIS
RichardLittlefield
Occasional Contributor II

I was in a similar situation. Using Attribute Rules to create an id, however didn't need the concatenate. The Text(Sequential Number, '0000') worked perfectly for adding leading zeros to your unique id with arcade expression in the attribute rules. Thanks!

0 Kudos
LanceCole
MVP Regular Contributor

I have not worked with this in Pro Attribute Rules but the Concatenate function in Arcade is Concatenate( values, separator?, format? ).  Try using the following in your return:

 

Concatenate(['wMET', nextsequencevalue("wMeterSeq")], '', '000')

 

 

 

 

jcarlson
MVP Esteemed Contributor

I'm so used to concatenating w/ a "+" I completely forgot about that. Nice!

- Josh Carlson
Kendall County GIS
GISUSER6
New Contributor III

Both of these processes worked. Thanks so much!

0 Kudos