Alternative with RAND funtion for generate ID Session

Hi all,

I am currently creating an ID identifier of a session, for that I use the function RAND(111111,999999), then I save that value in the database, so far so good.

To the above I want to add this:

  1. I concatenate the RAND function with the user ID, but the platform does not concatenate two integer and I do not see a function to concatenate, how can I solve it?

Thank you very much, I will be attentive to your answers.

Regards!

Hi,
You can achieve this in many ways, like:

  • using text properties instead of number properties to store your ID’s, you will not be making calculations with’em so why use number property?
  • using the randomizer component, put it on the screen you capture/create the ID on, add an invisible input then add an action to the randomizer (change input value>select the invisible input>“on value” select >randomizer then the option that suits you(in your case I guess unique ID will be great, it’s not a number it’s a string of letters and numbers)
1 Like

Thanks Benalihoussam! your first recommendation worked for me, indeed with a field of the text type it is solved.

Regarding your second comment, the truth is that I can’t follow you; that is to validate if the generated number already exists in the database?

Thank you very much.

Regards!

don’t worry about my second comment, it’s just another way of doing the same thing

1 Like

thanks you!

  1. You can use validation in this way.
  • Add a property “RandNumber” in the database
  • Add an hidden Input. The Input default value = RAND(111111, 999999).

On the Update Action :
RandNumber=Hidden Input
IDIdentifier = (Hidden Input)(ID)

Condition to do the action (“When does this happen”, at the end of the action)
All Users > Count
CUSTOM FILTER (ADD):
Current User > RandNumber IS EQUAL TO Input RandValue
IS EQUAL TO 0

This mean that the RandNumber is already in the database (count > 0), the action will not be done.

1 Like

thanks you Amber for you response!, I will test you recommend and will come back to response. Thanks!

Amber I was reviewing what you mention, but I have a doubt:

How can I apply that same, but at the moment of creating the record in the DB, at that moment I would like to generate a code that does not exist in the DB. Will it be possible with Adalo?

Thanks you!

generate a code that does not exist in the DB

It’s two different processus. You need to

  1. Generate your RAND number.
  2. Check if this Rand number exist in your DB
    3a. If not: Create your data in the DB
    3b. If so: Generate another RAND number (go back to 1)

Hello, well you can then create a collection called “Codes” and then add a condition to the RAND function action in which the codes=> count, then add a filter. Now make the filter in this way (Code is equal to generated code). Then write “0” in the number section below.

Thank you!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.