Unique ID of defined length
Is there some function that can create a unique ID (such as Get (UUID) ) but with a defined length? E.g. where I can define a total UUID length of 8 characters?
Why not the simple Filemaker field option to auto-enter a serial text, starting from 00000001 step 1 ?
What problem do you solve by specifying a fixed length? (knowing that can help us to help you.)
Try Auto-Enter the field with the following Calculated Value: Right ( Get ( UUID ) ; 8 )
Just keep in mind, the smaller the length, the more of a chance (though small) the value will not be unique.
NOTE: Sorry, edited this a few times, but I think I got it finally.
If you intend this unique identifier to be used as a Primary Key, Right ( Get ( UUID ) ; 8 ) sounds very unlikely to be reliable.
Why do you feel it is unreliable? This is not a smart ass question, just wondering if it has something to do with the way Filemaker creates a UUID. By my calculation, there is a 1 in 2.2 billion chance of a duplicate.
Correction: 2.8 trillion
I have no idea how the text in the UUID is generated. Is it solely a random number generation? I doubt that it is given the extremely complex format of the text provided but it could be. Thus, an ID generated from it, that only uses 22% of the entire text string isn't something I'd use for a Primary Key. I'm not fully at ease with using the complete Get ( UUID ) anyway and don't use it except for cases where there is an explicit advantage to using it (and there are lots of ways to get a fixed length serial number..)
The ideal primary key is:
That's why most properly set up primary keys in FileMaker databases are auto-entered serial numbers and a smaller subset use Get ( UUID ).
But let's keep in mind that we've never heard back from the original poster. This may not be for a Primary Key in the first place...
Dear Phil, dear Brent,
1) What should it be good for?
Not primarily for labeling electronic records but for labeling the "product entities" that are connected to each record. (-> pseudonym)
2) Why do I need a short one?
Because the UID is printed on a small label that will be sticked on the "product entity" and should be visually readable. Some large hash UID with 16 digits or whatever is just out of range in case that somebody wants to read/recognize a UID.
3) Ideal primary key:
I do agree with Phil on all four points ... actually not only agree: In our case it is a MUST -> Unique, no later changes, no included meaning! Any primary keys violating one of those three criteria are unsuitable for us.
I was hoping there might be an included function in filemaker, that I didn't find. Something like the version Brent had in mind "Get (UUID; 8)". But seems there is not. I'll probably have to find a different solution. :)
I suggest that you set up a serial number ID for this as it will be much simpler than the UUID value. The shorter, less unwieldy format of a serial number over a UUID is one of two reasons why I never use UUID unless there is a specific advantage to using it that out weighs the clumsiness of using one.
The following calculation can format a serial number with leading zeroes to produce an ID of the same fixed length in every case up to the maximum possible value of 99999. If you need more characters, just add more zeroes and increase the number parameter to match.
Right ( "0000" & SerialNumberField ; 5 )
Retrieving data ...