# Auto generate a UserID when a user signs up to my app

**URL:** <https://forum.adalo.com/t/auto-generate-a-userid-when-a-user-signs-up-to-my-app/5866>\
**Category:** Get Help\
**Created:** [November 11, 2020, 4:55pm UTC](https://forum.adalo.com/t/auto-generate-a-userid-when-a-user-signs-up-to-my-app/5866 "2020-11-11T16:55:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![msmurfitt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/msmurfitt/32/3410_2.png) [@msmurfitt](https://forum.adalo.com/u/msmurfitt)\
**Post date:** [November 11, 2020, 4:55pm UTC](https://forum.adalo.com/t/auto-generate-a-userid-when-a-user-signs-up-to-my-app/5866/1 "2020-11-11T16:55:46Z")

</div>

Hi,  
I need help to figure out how to auto generate a unique user id when a user signs up to my app.  
I have a user id property for each user, so I’d like each new user to have the previous user id +1.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/5/59f2b17ada8f81044e56f1fde7fc993de4395685.png)

What I’ve done so far is to attach a ‘create’ custom action on the submit button on the sign-up form referencing the ‘User ID’ property in Users collection to simply ‘+1’…but it’s not worked…and I can’t figure out why…

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/a/a949e9b94090cddaa770252205eda3f30e9a39d9.png)

I don’t have too many options available when amending the ‘User ID’ property, here’s what I see:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/6/65171c1ee2043938bea35e5293c34434d275890c.png)

I’ve been at this for hours and can’t figure it out…any help would be amazing.

---

<div class="post-metadata">

**Author:** ![msmurfitt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/msmurfitt/32/3410_2.png) [@msmurfitt](https://forum.adalo.com/u/msmurfitt)\
**Post date:** [November 11, 2020, 4:57pm UTC](https://forum.adalo.com/t/auto-generate-a-userid-when-a-user-signs-up-to-my-app/5866/2 "2020-11-11T16:57:01Z")

</div>

Oh, and I did look at this forum topic…but it’s just not worked…

> [@Auto Number Generation](https://forum.adalo.com/t/auto-number-generation/702):
>
> Is there away to populate a field with a unique number i.e order number/Contract Number?

---

<div class="post-metadata">

**Author:** ![iron49man](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/iron49man/32/2474_2.png) [@iron49man](https://forum.adalo.com/u/iron49man)\
**Post date:** [November 11, 2020, 5:43pm UTC](https://forum.adalo.com/t/auto-generate-a-userid-when-a-user-signs-up-to-my-app/5866/3 "2020-11-11T17:43:59Z")

</div>

You can’t edit the primary key ID for a record. It’s not like a SQL db where you can reference the id of the record and do math with it.

The best way to accomplish what you’re trying to do is to set the User ID to a function being a random number between a range. So click on magic text icon then hover over functions and use the “RAND” function. Set the range from 0 to 99999999999

---

<div class="post-metadata">

**Author:** ![msmurfitt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/msmurfitt/32/3410_2.png) [@msmurfitt](https://forum.adalo.com/u/msmurfitt)\
**Post date:** [November 11, 2020, 5:50pm UTC](https://forum.adalo.com/t/auto-generate-a-userid-when-a-user-signs-up-to-my-app/5866/4 "2020-11-11T17:50:51Z")

</div>

Hmmm, didn’t work.  
Here’s how I set the custom action:

 ![Screenshot 2020-11-11 at 17.48.25](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/5/5131c0efd4125650de581529fc4631ea6234282a.png)

I created a test user, checked in the collection…there wasn’t anything there ☹

 ![Screenshot 2020-11-11 at 17.47.49](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/1/154e2600d34b5941d7bb3cd64599f7124f55415a.png)

Did I do something wrong?  
Or miss something out…?

---

<div class="post-metadata">

**Author:** ![iron49man](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/iron49man/32/2474_2.png) [@iron49man](https://forum.adalo.com/u/iron49man)\
**Post date:** [November 11, 2020, 5:54pm UTC](https://forum.adalo.com/t/auto-generate-a-userid-when-a-user-signs-up-to-my-app/5866/5 "2020-11-11T17:54:18Z")

</div>

Well you also have 2 separate functions on the same action (Sign user up and Create User). So which one are you doing? If your form “Signs the user up” then you have to set the function immediately after it to “Update” the logged in user because you’ve already created the user in the first function. Even though it runs on the same singular action, the “Sign up” function runs first, then the “Update” function will run.

---

<div class="post-metadata">

**Author:** ![msmurfitt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/msmurfitt/32/3410_2.png) [@msmurfitt](https://forum.adalo.com/u/msmurfitt)\
**Post date:** [November 11, 2020, 6:03pm UTC](https://forum.adalo.com/t/auto-generate-a-userid-when-a-user-signs-up-to-my-app/5866/6 "2020-11-11T18:03:00Z")

</div>

Ok, that makes sense.

I’ve changed it the custom action to ‘Update’ and added the same random

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/3/3a01476abb8dde6750dec9fbcba1afebf5eb359d.png)

It didn’t populate the User ID property unfortunately…

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/1/1e592f125fe846683adca218e047a8944c515d80.png)

---

<div class="post-metadata">

**Author:** ![iron49man](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/iron49man/32/2474_2.png) [@iron49man](https://forum.adalo.com/u/iron49man)\
**Post date:** [November 11, 2020, 6:10pm UTC](https://forum.adalo.com/t/auto-generate-a-userid-when-a-user-signs-up-to-my-app/5866/7 "2020-11-11T18:10:49Z")

</div>

Instead of doing it this way, I would set it automatically on the form and remove the update statement altogether.

![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/5/53178ccabb4671f35910dee9d00ca11b8cdb3fe7.png)

---

<div class="post-metadata">

**Author:** ![base1](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/base1/32/6743_2.png) [@base1](https://forum.adalo.com/u/base1)\
**Post date:** [November 11, 2020, 9:16pm UTC](https://forum.adalo.com/t/auto-generate-a-userid-when-a-user-signs-up-to-my-app/5866/8 "2020-11-11T21:16:52Z")

</div>

What I’ve used that worked for me was to access the maximum ID of a table and add 1 to that. So if there’s no ID, 1 is the result. now there’s only one ID, its 1 and its the maximum, so the next will be 2. If I delete the record with the ID of 1, then 2 is still the maximum and the next will be 3.

![Screen Shot 2020-11-11 at 10.12.22 PM](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/f/fa3153a74c5157bcdbc8c7d40f80a8c2e7e0f6b0.png)

The difference with the RAND option is you will get incremented IDs instead of just random IDs. Also I think with just the RAND option there may be a far out possibility of repetition, though I’m not sure about it, but I know its not easy to set a unique fields Adalo yet.

---

<div class="post-metadata">

**Author:** ![msmurfitt](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/msmurfitt/32/3410_2.png) [@msmurfitt](https://forum.adalo.com/u/msmurfitt)\
**Post date:** [November 12, 2020, 1:10am UTC](https://forum.adalo.com/t/auto-generate-a-userid-when-a-user-signs-up-to-my-app/5866/9 "2020-11-12T01:10:47Z")

</div>

Great, thanks guys, it worked!  
Simple when you know how… lol 🙂

For those coming after who also have this problem, here’s a couple of screenshots of how it’s set up and what you should be looking for.

Create an ‘Automatic Field’ and clicking the magic symbole navigate to Users -\> User ID -\> Maximum and then add ‘+1’ and you’re done. (obviously you’ll have to create the ‘User ID’ property on your collection.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/adalo/original/2X/f/f2a5cabaea201d34c5e1edf4e73e32ed39c7e8c4.png)

---

<div class="post-metadata">

**Author:** ![RynoHospitality](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@RynoHospitality](https://forum.adalo.com/u/RynoHospitality)\
**Post date:** [November 13, 2020, 2:58pm UTC](https://forum.adalo.com/t/auto-generate-a-userid-when-a-user-signs-up-to-my-app/5866/10 "2020-11-13T14:58:46Z")

</div>

You can use the random # formula just give it a number like this Rand(1000,9999) if you don’t want/need them to be sequential.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.adalo.com/system/32/40401_2.png) [@system](https://forum.adalo.com/u/system)\
**Post date:** [November 23, 2020, 2:58pm UTC](https://forum.adalo.com/t/auto-generate-a-userid-when-a-user-signs-up-to-my-app/5866/11 "2020-11-23T14:58:47Z")

</div>

Closed on November 23, 2020, 2:58pm UTC

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