Once the user signs up in my app he is required to pick a username. Now I want to ensure that the username should not be duplicated in my database. i.e. If a user has already selected a username then that username should not be selected by someone else.
How should I go about this?
In a workflow:
“Only when” a search for that exact username = count:0
After “Username =” you will want to reference the input field for username that your user is submitting.
You may also want to match the search query by trimming the input field, and make sure to trim usernames before saving to the database.
From reference:
:trimmed
Removes the spaces at the beginning or the end of the text: ’ fd ’ → ‘fd’.
Umm. Did not get this one.
As of now this is my workflow. When the user clicks on the button this is what takes place. How should I go from here. I want to provide an error is the username already exsits otherwise create the username
You need to create an “Only when” condition on your workflow event, similar to the screenshot I shared. You need to prevent the workflow from firing if the username exists. You then create another event that fires when the username DOES exist and then you can specify an error message to display.
Is there a way to check the username is unique prior to submission?
For example, let’s say
- the user puts in their username in the field
- then they move to the next field (first name for example) - I want to know let them know through error messaging that the user should go back to the previous field and fix the user name else they will not be allowed to submit
Thanks
@fernando7 welcome to the community!
Yeap there is
- Set up a group of type yes/no and call it “check - is this name unique?”
- Use the event “an input value is changed” to detect when data is being entered into an input element of type text
- In “check - is this name unique?” run a search on the entered text against your database and count the number of results. If it greater than zero you know it is not unieque. The expression should look like this “search things :count > 0”
Now you have a yes or no that you can use to determine if your save button should be clickable or not. And you can also issue an alert informing the user if the name is not unique.
Hi @cmarchan
Just tried this, but since I’m a newbie, I’m stuck on how to use “check-is this name unique?”
Here’s what I have. What am I doing wrong? Thanks