I’m having trouble with terminating a workflow if a value exists in the database and think my ‘Do a search’ for may just be completely wrong.
I have a company input field on the signup page, and I basically want to prevent the sign up if any user account already exists with the same company name. I have a company field in the user data type to store this.
I’ve tried so many variations of ‘do a search for’ in the terminate workflow option I can’t even remember what I’ve already tried at this point, I’ve looked at a few other forum topics similar to this but I can’t seem to get a solution.
so what you are aiming for is using
do a search for user where companyname = inputs value: first item is empty or is not empty
is not empty means already in database user w company of this name exists, is empty means it is not
use this conditional on the button to make it clickable or not clickable.
Hi there, @aaron.marsh… adding to what TipLister said, you will need to make sure your privacy rules on the data type you are searching (which seems like it should be Company, but it sounds like you added a company field to the User data type and you are trying to search that field) allow for the company to be found by a non-logged-in user. If you are trying to search the User data type and you haven’t modified that data type’s default privacy rule, it’s not going to work.
You’ll need to add a search inside a conditional statement and then show an error; This name is already taken.
Personally I love using text elements, colored red.
Disable the button if the Error element is visible. Saves a bit of time trying to execute workflows and also prevents abuse by not allowing a user to make multiple searches by clicking times on the button.
Hi Guys, Thanks a lot for your help, it absolutely was due to the permissions - This didn’t even cross my mind.
A combination of both the suggested search function + permissions did the trick but I will take your advice and store the data in a Company table to keep the permissions for the user table private.
There’s just 1 issue with the query though, it sees capitalisation as different values and therefor doesn’t prevent the duplication. For example if an existing user has the company set as Apple then a new user tries to sign up with Apple, it will prevent sign up correctly but if the user enters apple all lower-case or something like ApPle, then signup is allowed. Is there a way to ignore capitalisation or would it be easier to just force capitalisation on the input in the first place so it’s not an issue?
You can force capitalization on input or you could set both values in the conditional to lowercase (or uppercase, if you want)… either way should work.
Ok, so I’ve got it working by using an invisible element which text is set to the company input box with uppercase transform as such
then in the workflows search function it references the invisible element’s text instead so it’s essentially always checking a hidden capitalized word for a capitalized word in the data table
then finally on the signup workflow assuming it hasn’t terminated at this point it stores the company name value from the invisible element instead so its always capitalized in the database.
I just need to modify it now so the company’s are stored in a separate table rather than the user table which should be easy enough so thanks both for all your help.