Calculate Sequential Integer for Repeats

233
8
Jump to solution
2 weeks ago
Blevins_Mark
Occasional Contributor

Is there a method to calculate a sequential integer field for the number of repeats, more specifically for a photo number. I want to populate a field as I add photo repeats, so that I have photo #1, photo #2, photo #3, etc...i was doing this using a count calculation, but have found that if i go back to a previous record before i submit the survey, the photo # value gets repopulated with the total (ie if i have 5 photo repeats all the photo #s get recalculated to "5", rather than 1, 2, 3, 4, 5.

Thanks

0 Kudos
1 Solution

Accepted Solutions
DougBrowning
MVP Esteemed Contributor

Add a once() around your count then it will not do that.  You can also use once(position(..)) but I have seen some bugs with it.

But note if a user goes back a few repeats and deletes a repeat then adds a new one you will get a dup.  No real way around this.  I personally gave up and instead number them all later when I export to to the file system in Python.  Way more reliable. 

Also we have had users name the site wrong at the start and then we fix it in QA.  But at that point all the photo names are then wrong.  Also had issues with users adding dup named photos.

It sounds great in theory if it all goes perfect but it never does.

Hope that helps

View solution in original post

0 Kudos
8 Replies
DougBrowning
MVP Esteemed Contributor

Add a once() around your count then it will not do that.  You can also use once(position(..)) but I have seen some bugs with it.

But note if a user goes back a few repeats and deletes a repeat then adds a new one you will get a dup.  No real way around this.  I personally gave up and instead number them all later when I export to to the file system in Python.  Way more reliable. 

Also we have had users name the site wrong at the start and then we fix it in QA.  But at that point all the photo names are then wrong.  Also had issues with users adding dup named photos.

It sounds great in theory if it all goes perfect but it never does.

Hope that helps

0 Kudos
abureaux
MVP Regular Contributor

I use a calculate with index(..) position(..) in my repeats. Then I use that for calculating image #. Essentially, it indexes your repeat starting at 1.

EDIT: Long week...

0 Kudos
DougBrowning
MVP Esteemed Contributor

I do not see index() listed in the functions and when I tested it the form says no such function?

DougBrowning_0-1714685083912.png

 

0 Kudos
Blevins_Mark
Occasional Contributor

Position (..) does what he was talking about. That’s pretty close to what I want. The order still gets a little out of whack if one of the repeats gets deleted before submitting, but all in all is pretty close to what I need and doesn’t have the issue of the numbers getting recalced if I browse through the repeats. Thanks all.

0 Kudos
DougBrowning
MVP Esteemed Contributor

You may still need to wrap it in a once() as I think it has got me before so I would test it.

0 Kudos
abureaux
MVP Regular Contributor

Two things.

For your auto numbering, do you just need it at the Feature Report level? In that case, have you considered using MS Word's quick parts? You can get auto numbering that way. I use it a lot for photos.

And just for the sake of clarity in case someone else stumbles across this in the future, this is the format for position(..)

abureaux_0-1714749400083.png

EDITED because it's been a long week...

0 Kudos
Blevins_Mark
Occasional Contributor

1. no it needs to be passed to the record in the feature layer primarily for map labeling purposes.

2. index(..) throws an error for me in connect. i've seen a couple of folks reference this but there is no index(..) in esri's survey123 formula documentation. however,  position(..) does pretty much what i need and is the same concept as indexing the record, wrapped in once() to ensure there are no duplicates in case one of the repeats gets deleted from the form before it is submitted.

thanks

0 Kudos
abureaux
MVP Regular Contributor

1) Darn...

2) It's been a long week. Ya, It's position(..)

0 Kudos