Attribute Assistant GENERATE_ID and then buffer with zeros?

793
5
12-05-2019 11:54 AM
Labels (1)
JonBrandt
New Contributor II

Is there a command to force my Unique ID to buffer it with zeros?

Not sure how to set it up in attribute assistant:  MANHOLE|0|SSMH[seq]  I've taken this and added MANHOLE|0|SSMH[seq].zfill(7)   This of course doesn't work, so what is the method for attribute assistant, do I use an arcade function?

FYI: In field calculator using python I can run the .zfill() on my text Unique ID field and then I'm able to sort numerically but I need that automated.

Ultimately I want my unique ID to look like this:  SSMH0015231

0 Kudos
5 Replies
JoeBorgione
MVP Emeritus

Attribute Assistant functions are visual basic so python and arcade aren't going to help you, at least within AA itself.  You might take a look at a python calculate or replace function after the fact.

edited to ad:  after a few moments of thought....

Would this work?   

MANHOLE|0|SSMH00[seq]

 

Just putting the 00 in between  SSMH and your [seq]

That should just about do it....
0 Kudos
JonBrandt
New Contributor II

Tried that.  It only works up to a point and isn't as clean as I'd like it.

0 Kudos
JoeBorgione
MVP Emeritus

Gotcha...

That should just about do it....
0 Kudos
AndyShoemaker
Esri Contributor

Hi John, 

Does every value need to have the extra padding or just values which are shorter than the full length you want?

For example, would you want   "0011"  and "0111" or would you want these to be "0011" and "00111"?

If you want the former, you can change the width of the integer generated so your expression would look like this "MANHOLE|4|SSMH[seq]". That should ensure the sequence is 4 digits and will pad with leading zeros 

Andy

Andy Shoemaker
0 Kudos
JoshVigness
New Contributor II

Jon,

I am not sure if you have found a solution to this issue or moved on but here is how I do this. The one difference is I am using this against an existing field so you would have to play around with trying to get it to work with your sequence name. 

"WMMH"&string(4-Len([gisid]),"0")&[gisid]

This returns WMMH0001

[gisid] is the field I am padding to create my new field.

Josh

0 Kudos