# Validate Unique Username entered by user

**URL:** https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370
**Category:** Project Showcase
**Created:** [June 24, 2020, 3:31pm UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370 "2020-06-24T15:31:36Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Raph](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/raph/32/9481_2.png) [@Raph](https://community.glideapps.com/u/Raph)
#### Post date: [June 24, 2020, 3:31pm UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/1 "2020-06-24T15:31:36Z")

</div>

Hello,

my users are loging in and at the moment i give them a unique username based on their email (every character before the @) + the 3 first characters from the Unique identifier

I’d like to offer them the possibility the change their username but i’m struggling to see how to prevent them from entering let’s say JOHN if JOHN already exists as a username for another user…

Any clue? Much much appreciated thank you

---

<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: [June 24, 2020, 3:35pm UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/2 "2020-06-24T15:35:15Z")

</div>

That “Edit” option makes it trickier I think.

To check if a value has already been entered in the database, my go-to method is:

- Create a user-specific column.
- Make a text entry that write to that column.
- Make a relation that matches the value in that column to the field I want to check if there’s a duplicate.
- Allow the value to be entered if there’s no match and vice versa.

I don’t think we can do that inside an Edit option though, is it the same as a Form?

---

<div class="post-metadata">

### Author: ![Raph](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/raph/32/9481_2.png) [@Raph](https://community.glideapps.com/u/Raph)
#### Post date: [June 24, 2020, 3:41pm UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/3 "2020-06-24T15:41:30Z")

</div>

> [@ThinhDinh](#):
>
> - Allow the value to be entered if there’s no match and vice versa.

thank you // how would you do this last step?

---

<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: [June 24, 2020, 3:57pm UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/4 "2020-06-24T15:57:29Z")

</div>

In my case, it was a booking app so it’s a completely new entry. I show them a button that links to a form and capture the entered value via a “Column”.

Never tried it with Edit option though, so I’m not sure if it works.

---

<div class="post-metadata">

### Author: ![Cmstewart42](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/cmstewart42/32/7319_2.png) [@Cmstewart42](https://community.glideapps.com/u/Cmstewart42)
#### Post date: [June 25, 2020, 6:01am UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/5 "2020-06-25T06:01:16Z")

</div>

Hello @Raph,

I currently have a similar need to validate a user entry with an arbitrary restriction such as duplication. What you could do is do the validation within the spreadsheet and once validated let the user “push” the validated username to the username field.

Unfortunately this would generally rule out using a form, as form values are not written to the spreadsheet until submitted and only write to new rows. However, what you could do is have a 2 step process:

1. User opens Change Username Page and is presented with a “Validate New Username” form button
  - User clicks the button and the form opens. The user enters their desired username into the only text field and hits submit
  - Their New Username is then logged in the “Username Request” sheet
  - An Excel formula then populates a few fields in the users ownered row (Latest New Name, Valid status)
  - User is automatically returned to Change Username Page (normal for forms)
  - Seconds later a component appears with the results of their validation a yes or a no and their chosen name
  - If yes, another new field will also be available: a choice component with only one possible value: the recently validated name (visibility based on the valid status)

2. The user now clicks the choice component and selects their validated name, which moves the validated name into the name column

Let me know if you would like more details as I have built and tested the above.

Good luck!

 ![1](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/9/98261e4bd236429ee94ffc626cc15e8394a1c40f.png) ![2](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/2/26c84e97df5fdfb32334837be24626c45ea588c4.png) ![3](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/c/cd1475344b99b60698ee40d8e3c60f0b0c2bc752.png) ![4](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/d/d5cf4c69815fa3ad75312bf0a80d42c905a9fea5.png) ![5](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/b/b2aae584039e77f80abd5acd880f2f319e2314f8.png)

---

<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: [June 25, 2020, 7:54am UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/6 "2020-06-25T07:54:18Z")

</div>

Would this method encounter a lag when you have to submit it back to the Sheets though? If you are using a form to validate it, then I would rather do a relation in that same “Validation” sheet as you have stated, to know if it matches an existing record or not. I think pushing it back to the Sheets is not ideal.

Furthermore, I think it will eat up a lot of rows for the validation and free users won’t like that. Kudos to the idea for the choice component.

---

<div class="post-metadata">

### Author: ![Cmstewart42](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/cmstewart42/32/7319_2.png) [@Cmstewart42](https://community.glideapps.com/u/Cmstewart42)
#### Post date: [June 25, 2020, 8:00am UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/7 "2020-06-25T08:00:15Z")

</div>

Hi @ThinhDinh,

- The reason I pushed it back to the sheet for validation is that it offers more options. You can do any sort of validation you like.
- The delay is there of course, anything that goes back to the sheet will have it, but its maybe 2sec, not too bad
- There are no extra rows used for validation, only for the request submission, and if you are familiar with AppScripts, you could arguably delete the top X number of rows anytime the number of rows reaches some threshold. Also the form ensures that the value, once validated, cannot be changed by the user. This ensures the validation remains true.

The issue is that at any time, if the user is free to enter a value in a free text field, you cannot validate it. Using a pre validated value that is simply selected from a list, ensures the value is valid.

I will admit its not a perfect solution, but it is functional and fairly straight forward.

Thanks for the feedback.

---

<div class="post-metadata">

### Author: ![Raph](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/raph/32/9481_2.png) [@Raph](https://community.glideapps.com/u/Raph)
#### Post date: [June 25, 2020, 8:04am UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/8 "2020-06-25T08:04:14Z")

</div>

thanks, perfect workaround.

---

<div class="post-metadata">

### Author: ![Cmstewart42](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/cmstewart42/32/7319_2.png) [@Cmstewart42](https://community.glideapps.com/u/Cmstewart42)
#### Post date: [June 25, 2020, 8:04am UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/9 "2020-06-25T08:04:47Z")

</div>

Great, glad it was clear enough for you.

Let me know if you need anything else!

---

<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: [June 25, 2020, 8:13am UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/10 "2020-06-25T08:13:03Z")

</div>

> [@Cmstewart42](#):
>
> The issue is that at any time, if the user is free to enter a value in a free text field, you cannot validate it.

I think that is achievable with a user-specific column. Using your same method above, it would go like this:

- User enters their new name using that user-specific entry.
- A relation validates if that entry is not a duplication of any existing entries.
- If the relation is empty, then show the choice component to let the user change it, with the only value being the value in the user-specific column. Otherwise don’t show the choice component and show a text that the name is not available.

In my experience, pushing it back to the sheets require more than 2 seconds to bring back the value to the Glide editor and then sync it to the device of the user, so many of us here have always tried to find some ways to do it inside the Editor instead, lagging troubleshoot is a concerned issue we have discussed many times here.

All in all, nice workaround using the Sheets, and if Raph wants to try the steps I listed in this comment, feel free to do so and let us know if you succeed.

Thank you all 😄

---

<div class="post-metadata">

### Author: ![Cmstewart42](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/cmstewart42/32/7319_2.png) [@Cmstewart42](https://community.glideapps.com/u/Cmstewart42)
#### Post date: [June 25, 2020, 8:17am UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/11 "2020-06-25T08:17:05Z")

</div>

If it’s possible I agree it could be quicker, however I also like to camel case their name and in general if this is to be used for any complex validation, the editor will likely not suffice. Though if duplication is the only criteria and things like first letter capitalisation are not required, then keeping it in the editor may also do the trick!

---

<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: [June 25, 2020, 8:21am UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/12 "2020-06-25T08:21:22Z")

</div>

I agree with that, if we need further adjustments on the value, like what you say, camel case the name then we must bring it back to the Sheets.

It also brings me to the question that whether my relation goes the way of exact match or not (i.e Camel is not the same as cAmEl and won’t bring back a relation value ).

---

<div class="post-metadata">

### Author: ![Cmstewart42](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/cmstewart42/32/7319_2.png) [@Cmstewart42](https://community.glideapps.com/u/Cmstewart42)
#### Post date: [June 25, 2020, 8:23am UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/13 "2020-06-25T08:23:09Z")

</div>

To me for a function that will happen seldomly a small lag to gain the flexibility of sheets is an easy concession to make.

---

<div class="post-metadata">

### Author: ![Raph](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/raph/32/9481_2.png) [@Raph](https://community.glideapps.com/u/Raph)
#### Post date: [June 25, 2020, 8:11pm UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/14 "2020-06-25T20:11:39Z")

</div>

I’ll try this one too and let you know, thanks !

---

<div class="post-metadata">

### Author: ![Mridula\_R](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@Mridula\_R](https://community.glideapps.com/u/Mridula_R)
#### Post date: [March 2, 2022, 11:53am UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/15 "2022-03-02T11:53:11Z")

</div>

> [@ThinhDinh](#):
>
> A relation validates if that entry is not a duplication of any existing entries.

Hi, I’m struggling with exactly this right now! 🙂 - I have such a relation column set up and it works fine if I directly enter the value in the glide table. But, naturally that’s not how the app will work - I want my ‘primary’ user to be able to add new (secondary) users - is there _any_ way that I can assign the new user’s ID to a temporary variable? I have a column for the temporary variable which what the relationship checks the list of user IDs against. If I use the action ‘set value’ for some reason the value from the form isn’t getting captured in the table at all… what am I doing wrong?

If this helps, this is my form:  
 ![clunk](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/2/12f7d66a472350129464069d2302513e6003ccc7.png)  
I thought I’d use the clunky manual check button to force a check that the ID is unique before proceeding to fill the whole form. But set column value \> this row isn’t adding the value to the admin user’s column.

And, the second weird thing is that while my user ID column is user-specific, I can apparently still have a duplicate entry!

 ![Redundancy](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/c/4/c48c0c70a92edaf026461a0f6ed8135fd136101c.png)  
Why is this possible?

---

<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: [March 2, 2022, 12:00pm UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/16 "2022-03-02T12:00:35Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/3/f344bea6747d646fee21cc8e30ad20585d7dc7fa.png)

Is this a native form? The method I mentioned only works with custom forms.

> [@How do I create a custom form?](https://community.glideapps.com/t/how-do-i-create-a-custom-form/25014):
>
> I’m just dropping this here so I have something to refer people to when they ask. This is a simple concept app (copyable), that demonstrates the following techniques: Building custom forms for adding and editing list items (as an alternative to the native forms provided by Glide) Preventing duplicate new entries using [User Specific Columns](https://docs.glideapps.com/all/reference/data-editor/user-specific-columns) and [Relations](https://docs.glideapps.com/all/reference/data-editor/computed-columns/relation-column) Enforcing mandatory input items The use of visibility conditions and user specific booleans to control user flow There is nothing particula…

---

<div class="post-metadata">

### Author: ![Mridula\_R](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@Mridula\_R](https://community.glideapps.com/u/Mridula_R)
#### Post date: [March 2, 2022, 12:07pm UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/17 "2022-03-02T12:07:27Z")

</div>

Er, sorry, I’m not sure - I called it using “show form screen” from an Add button?

---

<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: [March 2, 2022, 12:18pm UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/18 "2022-03-02T12:18:33Z")

</div>

Yes, that’s what I refer to as “native form”.

Please read the “custom form” thread I linked above.

---

<div class="post-metadata">

### Author: ![Mridula\_R](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@Mridula\_R](https://community.glideapps.com/u/Mridula_R)
#### Post date: [March 2, 2022, 12:27pm UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/19 "2022-03-02T12:27:36Z")

</div>

ohhh! sorry sorry, thanks a ton!

---

<div class="post-metadata">

### Author: ![Jeff\_Hager](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/jeff_hager/32/43_2.png) [@Jeff\_Hager](https://community.glideapps.com/u/Jeff_Hager)
#### Post date: [March 2, 2022, 12:41pm UTC](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370/20 "2022-03-02T12:41:12Z")

</div>

Also, you may be misunderstanding user specific columns. They don’t ensure that every value in the column is unique. What they do is hold a value uniquely, for each user that’s signed in. You see numbers in that column now, but if a different user signed in, then that entire ID column would be empty.

The purpose of a user specific column is so that multiple users can store a value in one single cell that’s unique to them. Nobody else will see what they entered.

[Next page](https://community.glideapps.com/t/validate-unique-username-entered-by-user/11370.md?page=2)
