# How can I create unique Identifiers in my app? (UUID)

**URL:** https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450
**Category:** Questions about Thunkable X
**Created:** [March 26, 2022, 1:59pm UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450 "2022-03-26T13:59:22Z")
**Posts on this page:** 17
**Page:** 1

<div class="post-metadata">

### Author: ![pdh1982](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@pdh1982](https://community.thunkable.com/u/pdh1982)
#### Post date: [March 26, 2022, 1:59pm UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/1 "2022-03-26T13:59:22Z")

</div>

1. i’ve search fourm, and with thunkable, we cant get IMEI, phone number, so can we create a random number (ID) and set to phone, when close app and open app again, this number (ID) wont change, can we do this ?
2. And in my app, there too much products in colum A (google sheet), and i have textbox1, how i can search data in textbox1.text (user input data in textbox1) in colum A, if textbox1.text have on colum A and do somethings, else do something …  
Thank you.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [March 26, 2022, 3:47pm UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/2 "2022-03-26T15:47:58Z")

</div>

1. Yes. If you create a random value and set a Stored variable to it, the device will remember the value.

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 26, 2022, 4:53pm UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/3 "2022-03-26T16:53:41Z")

</div>

I use a roundabout way to get a **unique** number that won’t repeat.

I create a local table in the project and every time I need a unique number generated, I use the `create row` block  
 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/8/488de5f612fce67e55555619e3cd2ac308469f8d.png)

Every new row created will have the `green block row id` which is a **unique** number which I use it in my project.

---

<div class="post-metadata">

### Author: ![pdh1982](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@pdh1982](https://community.thunkable.com/u/pdh1982)
#### Post date: [March 27, 2022, 12:45am UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/4 "2022-03-27T00:45:05Z")

</div>

device will remember tha value event i close app, turn the phone off ?

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [March 27, 2022, 1:08am UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/5 "2022-03-27T01:08:14Z")

</div>

Yes. Until you uninstall the app.

---

<div class="post-metadata">

### Author: ![pdh1982](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@pdh1982](https://community.thunkable.com/u/pdh1982)
#### Post date: [March 27, 2022, 2:38am UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/6 "2022-03-27T02:38:52Z")

</div>

![1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/6/6/66b7c1a2d38a2b262555d75f32497a19f1970f31.png)  
How i can store variable ID ?  
i think this block always create random value and store it, so variable ID not the same ?

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [March 27, 2022, 5:15am UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/7 "2022-03-27T05:15:17Z")

</div>

Don’t use local storage. When you use the set app variable block, change the app drop-down menu to stored. So it will say “set stored variable \_\_\_\_\_ to”.

Also, you don’t want to use another variable block for the variable name. Just use the “set” variable block that has the name of the variable that you initialized.

---

<div class="post-metadata">

### Author: ![pdh1982](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@pdh1982](https://community.thunkable.com/u/pdh1982)
#### Post date: [March 27, 2022, 5:21am UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/8 "2022-03-27T05:21:51Z")

</div>

Thank you for your help, but i dont understand your mean “app drop-down menu” ?  
Can you make me some blocks ?

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [March 27, 2022, 6:08am UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/9 "2022-03-27T06:08:08Z")

</div>

Here’s a screencast of creating and using a stored variable:

[https://watch.screencastify.com/v/GlBsPws9qtqZXYfSk5Wz](https://watch.screencastify.com/v/GlBsPws9qtqZXYfSk5Wz)

Note: I initially added an Else section to the If block but then realized I didn’t need it. Also, you’ll see that I check for a null value for the stored variable and set it to zero (or any starting value) if it’s null. I believe this is standard practice but I honestly don’t know why it has to be done.

---

<div class="post-metadata">

### Author: ![pdh1982](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@pdh1982](https://community.thunkable.com/u/pdh1982)
#### Post date: [March 27, 2022, 6:44am UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/10 "2022-03-27T06:44:07Z")

</div>

![1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/b/2b1492e277e39e1aaf4d88e7ff24f4218cf72487.png)  
Am I doing it right ? I dont see any block to set stored variable ID to device ? when i test with component, it always a random number

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [March 27, 2022, 6:52am UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/11 "2022-03-27T06:52:45Z")

</div>

No. You should not be using Local Storage blocks. Those have been discontinued.

Please refer to my video. Here’s a screenshot of the blocks from it:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/f/4/f458f738d898126296dd1c0e8938c9c51169f9e5.png)

The second to last block saves the random number in the stored variable. The last block displays the saved value. The thing is, if you run this more than once, it’s going to set a new value. So you may want to only set the random ID once. You can do this by saying If stored variable random ID = 0 then set stored variable random ID to random integer from 1000000 to 9999999. That way, once it’s set to a new value, it won’t ever be set again.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [March 27, 2022, 6:57am UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/12 "2022-03-27T06:57:00Z")

</div>

Here’s a simplified version:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/c/9/c96793a95e2f75936d1d41df9ea122c7645f9142.png)

Test it **on a mobile device** by opening the app a few times. You’ll see that it sets a value and then displays that same value every time.

---

<div class="post-metadata">

### Author: ![pdh1982](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@pdh1982](https://community.thunkable.com/u/pdh1982)
#### Post date: [March 27, 2022, 7:00am UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/13 "2022-03-27T07:00:20Z")

</div>

thank you very much.

---

<div class="post-metadata">

### Author: ![pdh1982](https://avatars.discourse-cdn.com/v4/letter/p/edb3f5/32.png) [@pdh1982](https://community.thunkable.com/u/pdh1982)
#### Post date: [March 27, 2022, 1:12pm UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/14 "2022-03-27T13:12:48Z")

</div>

Can u suggest how can i check, if stored variable have on colum A ( google sheets ) and do somethings, in kodular i can call with web1.get and check, with xthunkable, im new so hope you will help.

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [March 27, 2022, 2:11pm UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/15 "2022-03-27T14:11:45Z")

</div>

Hey @phamduyhoang1982nc Firebase a userID would be a solid unique identifier to use. Why not use that? It’s a secure way to login and provides a unique identifier to each signed up user per Firebase project.

Alternatively you can make a GET call to this UUID generator!

```auto
https://www.uuidtools.com/api/generate/v4

```

The random integer route is _ok_ but potentially leads to more chances for duplicates than the route above. That said, the above only works when your connected to the internet so 🤷‍♂️

---

<div class="post-metadata">

### Author: ![muneer](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/muneer/32/75210_2.png) [@muneer](https://community.thunkable.com/u/muneer)
#### Post date: [March 27, 2022, 6:03pm UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/17 "2022-03-27T18:03:37Z")

</div>

> [@jared](#):
>
> Alternatively you can make a GET call to this UUID generator!

alternatively, generate your own

```auto
    function new_uuid() {
        return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
            var r = Math.random() * 16 | 0, v = c == 'x' ? r : (r & 0x3 | 0x8);
            return v.toString(16);
        });
    }

```

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/f/0f59f292712368bce16ff80133ae10de8a6f27e8.png) [@system](https://community.thunkable.com/u/system)
#### Post date: [June 25, 2022, 6:04pm UTC](https://community.thunkable.com/t/how-can-i-create-unique-identifiers-in-my-app-uuid/1803450/18 "2022-06-25T18:04:32Z")

</div>

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