Create standard format number

Hi All,

i need opinion on how to created standard format number with condition,

the number wont duplicate base on db either localdb, airtable or spreadsheet.

following block is ok but new session will duplicate the number or if system have multiple user it will duplicate also.

image

You can use the “seconds since 1970” block to create a unique number or text string. Or you can use Firebase sign-in to create a unique UserID. That’s what I’d recommend.

1 Like

Hi @tatiang

Thank you for your respond. i am not sure block “Seconds since 1970” relevant for my solution.
i never use it before and from what i understand it related with timestamp?

Yes, it’s a time stamp. Seconds since 1970 would give you a number like this:

1621304086

And then a second later:

1621304087

And so on… but always unique.

Can you give an example of a series of numbers that would work for you? And a series of numbers that would not?

i only want to create set of number for example from 100-200. it need to follow standard formation not a random number. And most important is not duplicate even though it has multiple users who using the app. that why i though it need to compare at DB either localdb or airtable so the user will get free available formation number from the list.

1 Like

Okay so yes, you would need to check the existing data before assigning a new number to a user.

You can’t use a local database because you need other users on different devices (I assume) to also be assigned numbers.

So airtable could work. Create a new row for each new user but before assigning a number to them, check all rows to see if that number exists.

1 Like

@tatiang

how to bypass when it reach duplicate number? now i try on local db later i will create at airtable.
in local db i already have record 1,2. total number i set to 10.
if list variable i set to 3 then should be fine but imagine i have multiple user who create a number the sequence probably 1,3,5 then i believed it should by pass and get available number.

1 Like

Do exactly what you are doing in the else part of the block. [Change app variable list] by 1 to get the next number and check again.

Better to reorder your block to check only for none duplicates for example to go into a loop and use the [break] block if the number is not a duplicate.

@muneer

first method: how to get next number and check again?
second method: if possible to get sample from block because i never use looping or break block before.

1 Like

See this example
https://x.thunkable.com/projectPage/60a4e8623fb2e80012cea340

It will check for the next available number in a given range and it will also check if no more numbers are available.

You can check for next available numbers many times and once you decide to reserve the number it will be added to the list of reserved number so next time you check for available numbers the number added will not show as an available number.

HI @muneer

i got this message when click on link given. probably is not public yet?

1 Like

Here is the link again. It is public

https://x.thunkable.com/projectPage/60a4e8623fb2e80012cea340

thank you muneer. appreciated you help. seem a bit complex but let me study and try to apply from my existing block.

1 Like