Unique Code Creation customized way

Hi I would like to get advice on uniqeid creation, is there any way to make the customized auto generated unique id instead of what appsheet generate.

I would need to have DATE+Unique Alphaphat leters + Unique Number

Example : 08252022-ABC-0011

I tried to combine date clm + Row number but still it's not fulfilling my req. even date come as 08/25/2022

 

Any sollutions?

 

 

 

Solved Solved
0 6 179
1 ACCEPTED SOLUTION

Building on @SkrOYC's information regarding date:

CONCATENATE(
  TEXT(TODAY(), "MMDDYYYY"), 
  "-", 
  MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ", RANDBETWEEN(1, 26), 1), 
  MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ", RANDBETWEEN(1, 26), 1), 
  MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ", RANDBETWEEN(1, 26), 1), 
  "-", 
  TEXT(RANDBETWEEN(0, 9)), 
  TEXT(RANDBETWEEN(0, 9)), 
  TEXT(RANDBETWEEN(0, 9)), 
  TEXT(RANDBETWEEN(0, 9))
  )

View solution in original post

6 REPLIES 6

Your "Unique Number" needs to be sequential? Be aware that sequential numbering is not supported by default on AppSheet and even if you use workarounds you can't control the fact that two rows could end up using the same number.

About the date drama, take a look at the docs:

TEXT() - AppSheet Help

SkrOYC_0-1661380359923.png

In your case, TEXT([Date], "MMDDYYYY") will return the date formated the way you expect

Building on @SkrOYC's information regarding date:

CONCATENATE(
  TEXT(TODAY(), "MMDDYYYY"), 
  "-", 
  MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ", RANDBETWEEN(1, 26), 1), 
  MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ", RANDBETWEEN(1, 26), 1), 
  MID("ABCDEFGHIJKLMNOPQRSTUVWXYZ", RANDBETWEEN(1, 26), 1), 
  "-", 
  TEXT(RANDBETWEEN(0, 9)), 
  TEXT(RANDBETWEEN(0, 9)), 
  TEXT(RANDBETWEEN(0, 9)), 
  TEXT(RANDBETWEEN(0, 9))
  )

Basically correct, although I don't know how unique the last part could be and since we are talking about the key column we can't correct it if there are two rows with the same "unique" number.

This is one of the best explanations about why sequential (which is the ideal setup IMHO for "unique numbers") is not supported:

Sequential keys - AppSheet Help

I didn't appreciate that the intent here is for a key column. Of course, that's ill-advised.

Additional info for @Saraappsheet's reference: Serial Numbers, If You Must - Google Cloud Community


@Steve wrote:

Danger Ahead!

In general, sequential numeric identifiers (i.e., serial numbers) are risky in AppSheet: if two users happen to add rows at the same time, both rows could be assigned the same serial number, which could lead to confusion (at the least) or data loss (at the worst). For this reason, serial numbers are strongly discouraged!


^ Some explicit and direct reference from the same post ^

In any case, @Saraappsheet haven't confirmed that he needs sequential, although the problem is the same

This works as I expected. thanks a lot geneius!

Top Labels in this Space