Tracking Nested Repeat Records for Unique IDs

204
2
07-28-2023 02:12 PM
BrandonGregg
New Contributor II

I am building a form for electro-fishing which has a nested repeat 

- main layer : waterbody/stream and year (MAIN)

- first repeat: location of electro-fishing  (LOCATION)

- second repeat: individual fish at location of electro-fishing (FISH)

The team will sometimes electrofish at multiple locations at the same waterbody on the same day. They will also sometimes return to that waterbody within the same year. 

The problem I'm having is generating unique ID's between all tables, specifically the (FISH) IDs.

The team has an existing database and the fish IDs are continuous over visits. 

For example: 

sample 1: July 28 (15 fish collected) - fish IDs would range from ABC-1 to ABC-15

sample 2: July 28 (10 fish collected) - ABC-16 to ABC- 25 

sample 3: Aug 14 (20 fish collected) - ABC-26 to ABC-45

For each fish sample, I want to generate a unique ID that identifies the (LOCATION) and would look something like this 

sample 1: ABC-July 28 - 1

sample 2: ABC - July 28 -2

sample 3: ABC - Aug 14 - 1

If I keep the first and second repeats separate (and not nested) then I can automatically keep track of the correct Fish ID using position(..). However when I do this, the (LOCATION) ID  changes to the newest LOCATION ID 

If I keep them nested, which I feel is much cleaner when in the field, then the (FISH) ID resets at 1 everytime you create a new (LOCATION) 

 

* all collection would be offline so there isn't the option to send the survey and then edit using the inbox for multiple visits at one location in the same day

Any advice or workarounds would be appreciated ! Happy to share snippets of the XLS form ! 

0 Kudos
2 Replies
DougBrowning
MVP Esteemed Contributor

One idea is to index them with the first repeat.  So 1-1, 1-2, 1-3 then 2-1, 2-2, 2-3, etc.

But be aware if a user goes back in the repeat and deletes say 2-2 then you will get two 2-3s since position will be 3 on the next add, and your other 3 is still there.  It may start to drive you nuts as this can happen on the regular.  We tell out crews never to go backwards and delete and it has kinda worked.

Then we just stopped worrying about sequential numbers.  What would you use them for anyway really.  Most times you want a count, avg, etc. People are used to seeing it but what is the use case?

Something to think about.  Hope that helps

0 Kudos
BrandonGregg
New Contributor II

Thanks Doug.  That is a solution that works and what I will suggest it to the team. Good to know about the limitation before I do. 

I don't think they NEED the sequential numbering, and certainly not the continuous numbering of fish between different visits. But since they have an existing database using this method , for consistency I wanted to find out if there was a way to do it. 

0 Kudos