# A nice trick to make unique codes in Glide (without GSheets)

**URL:** <https://community.glideapps.com/t/a-nice-trick-to-make-unique-codes-in-glide-without-gsheets/26652>\
**Category:** Project Showcase\
**Created:** [May 11, 2021, 8:31pm UTC](https://community.glideapps.com/t/a-nice-trick-to-make-unique-codes-in-glide-without-gsheets/26652 "2021-05-11T20:31:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Turrell](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_turrell/32/26605_2.png) [@Mark\_Turrell](https://community.glideapps.com/u/Mark_Turrell)\
**Post date:** [May 11, 2021, 8:31pm UTC](https://community.glideapps.com/t/a-nice-trick-to-make-unique-codes-in-glide-without-gsheets/26652/1 "2021-05-11T20:31:54Z")

</div>

The challenge - how to make a unique random code in Glide … without using GSheets (slow, etc).

The @Darren_Murphy trick:

1. lookup table with a single column full of characters that you want to include (in my case, I exclude some numbers and letters are they might be confusing to read or say)
2. in the table where I will need the code, my two-character code is made up of two single value columns, both picking **random** values from the lookup + a template column that combines them together
3. in my app, I have a moment when the user needs to click on a button to initiate a process. At that point I have an action that does Set Columns, taking the continuously changing 2-char string… and bakes it into a ‘Code’ column, to set it for the process.

Magic! And gets rid of the last GSheet formula I was stuck with 🙂

![Screenshot 2021-05-11 at 22.25.38](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/b/2/b25778abd7d9e85e191730e602a4badcbaf5fcc8.png)

 ![Screenshot 2021-05-11 at 22.25.50](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/d/ad50aeda5b84717f48393f9739f8e30ae078456e.png)  
 ![Screenshot 2021-05-11 at 22.26.27](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/a/d/ad27c95d64d00f8ba14405675888e28f17d73334.png)

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [May 12, 2021, 12:42am UTC](https://community.glideapps.com/t/a-nice-trick-to-make-unique-codes-in-glide-without-gsheets/26652/2 "2021-05-12T00:42:44Z")

</div>

> [@Mark\_Turrell](#):
>
> how to make a unique random code in Glide

I wouldn’t exactly call it unique… but then that wasn’t a requirement, eh? 😉

---

<div class="post-metadata">

**Author:** ![Mark\_Turrell](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_turrell/32/26605_2.png) [@Mark\_Turrell](https://community.glideapps.com/u/Mark_Turrell)\
**Post date:** [May 12, 2021, 4:57am UTC](https://community.glideapps.com/t/a-nice-trick-to-make-unique-codes-in-glide-without-gsheets/26652/3 "2021-05-12T04:57:52Z")

</div>

Let’s call it ‘unique enough’ for the requirement 🙂 🙂

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 12, 2021, 10:08am UTC](https://community.glideapps.com/t/a-nice-trick-to-make-unique-codes-in-glide-without-gsheets/26652/4 "2021-05-12T10:08:43Z")

</div>

Would a combo action fire quick enough if you include a relation to check for duplications, then if the relation is not empty, let’s say reshuffle and then set column?

As I was typing this, I’m thinking if it generates a duplicate again then it also won’t work 😅

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [May 12, 2021, 10:21am UTC](https://community.glideapps.com/t/a-nice-trick-to-make-unique-codes-in-glide-without-gsheets/26652/5 "2021-05-12T10:21:42Z")

</div>

If we wanted something truly unique, then I think we’d just use RowID and be done with it 😂

---

<div class="post-metadata">

**Author:** ![Mark\_Turrell](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/mark_turrell/32/26605_2.png) [@Mark\_Turrell](https://community.glideapps.com/u/Mark_Turrell)\
**Post date:** [May 12, 2021, 10:26am UTC](https://community.glideapps.com/t/a-nice-trick-to-make-unique-codes-in-glide-without-gsheets/26652/6 "2021-05-12T10:26:03Z")

</div>

in my case the only issue would be the same user gets the same code at some point over the next months. It is not a disaster though, as the user needs to also do a drawing… and they have to use the camera (on mobile) to upload their photos. And we do a date check in the EXIF data from the photo to see when the photo was originally saved… and validate that against the timestamp of when the process started.

---

<div class="post-metadata">

**Author:** ![ehdubya](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ehdubya/32/24087_2.png) [@ehdubya](https://community.glideapps.com/u/ehdubya)\
**Post date:** [May 12, 2021, 12:59pm UTC](https://community.glideapps.com/t/a-nice-trick-to-make-unique-codes-in-glide-without-gsheets/26652/7 "2021-05-12T12:59:13Z")

</div>

This may be of some use for random codes generated with sheets…

> **[Google Sheets - Random Alphabetic, Random Alphanumeric and Random Alphanumeric...](https://www.google.ca/amp/s/yagisanatode.com/2018/08/23/google-sheets-random-alphabetic-random-alphanumeric-and-random-alphanumeric-character-custom-functions/amp/)**
>
> Google Sheets, Google Apps Script I was working on a Spreadsheet in Google Sheets a few days ago and needed to generate some random codes for my users. To do this, I just used the RANDBETWEEN(start val, end val) function built into Google Sheets. It...
