Custom Generated Unique ID Length not Fixed

Good day all,
I wanted to generate a consistent unique identifier with a fixed length of 10 digits in KoboToolbox.Anytime, i generate the unique id, the digits are not consistent, some are 4digits, some 10digits, what could be the issue
This is my expression:
once(substr(translate(substr(uuid(), 1, 20), "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-", ""), 1, 10))

Is there a reason you aren't supplying an argument to the uuid expression to specify the length?
That is, using just: uuid(10)


@danbjoseph, i just want to generate a unique 10 digit numbers devoid of other characters to enable me, create identifiers for registrants. Mixing other characters and so much characters, makes the presentation unclean to me.
The issues, is that the expression above works properly, but the numbers generated are flutuating in lengths or size. some comes as 4 digits, some 6 digits etc

Thank you

If I'm reading your expression correctly, you're extracting 20 characters, removing any letters and dashes, and then extracting 10 characters from that string. If your 20 characters have more than 10 letters and dashes, then you won't have enough characters left to take another substring of 10 length.

I recommend considering different methods of creating a unique identifier. Or, if possible, adjust your workflow to generate the unique identifiers after the initial surveys are completed. Here is a discussion on offline generation of unique IDs to ensure no duplicates that may be useful:

@danbjoseph ,the problems of using date and time,is when device you are using to capture respondents,has faulty timer, or device time is inaccurate it may generate inconsistence date and time,calculation. Such a thing has happened to me with Samsung galaxy TAB E,where my unique identifiers generated from date and time calculations results to fixed unique ids in a repeat questions for every single submission_id or uuid.

if the problem is that the uuid doesn't have >10 numbers in it, what about changing your expression to this:
once(substr(translate(uuid(100), "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-", ""), 0, 10))

note: the substr() arguments are 0-indexed so substr(string,1,10) returns a string of length 9, and for a 10 digit string you'll want substr(string,0,10)

Thank you @danbjoseph ,
I will consider the trade-offs between the three approach,using the one with seed values of 100 and the one without it.

While the identifiers generated are fixed in lenght ,The expression uses a seed value (100), which can introduce some level of predictability and potentially increase the likelihood of collisions if the same seed is used frequently.
Compatibility: The generated IDs might deviate from standard UUIDs, potentially causing compatibility issues with systems or processes that expect UUIDs standards.

Generating the unique id with uuid() , might solve the problem,because of less chances of collison,using the birthday paradox.
However, The characters genenerated are always long.

allowing the uuid with no seed in it and removing the non-numeric characters from it,with a changing lengths of unique identifiers, or adjusting the numbers of characters from the uuid (), upward before extracting.

These are the trade-offs i might consider.

It is the randomize() expression that can accept a numeric seed argument in order to make it deterministic and reproducible. The numeric argument in uuid() changes it to return a random GUID of specified length.