Forum Documentation Showcase Pricing Learn more

Restrict search box input text to recognise existing strings in different case - not allow different case input and save for the same word


#1

HI Bubblers

So, I have a search box that is used in an input form to help eliminate duplication.

  1. When the user enters the first few letters of the string, if the first couple of characters in the string exists it will show the current saved string records that begin with those characters. This works great and the user can select the existing string and it is saved when the form is submitted.

  2. If the first couple of characters in the string do NOT exists, the user can also choose to add a new string in the same field and save the form and the new string will be added in the search table along with the existing records.

  3. The workflow logic is such that if the user enters a string which exists it saves the rest of the form but does not create an additional record in the ‘search box’ table so this is all working as expected.

  4. However, if I enter an existing string with different case it will create a new search box record, and I do not want this - the search box appears to be case sensitive by default.

  5. So what I am looking for a is a solution to identify the same string in a different letter case if it already exists in the search box record so it does not create an identical string with different case.

For example;

  • If I have a record = NORTH

  • I start typing the word and it pops up along with NORTH WEST - because they begin with NO

  • But, I can also type “north” and even though it brings up the same options I can choose to type it “nORTH” and the issue is generally happening because of user keyboard error.

  • So I want the workflow to be able to recognise that “nORTH” is the same as “NORTH” and not create the new search box record: “nORTH”.

  • Clearly the issue is that it could also be typed: “north”, North" etc… but I need it to recoginse that “NORTH” is the same word and already exists so it does not save a new record just uses the existing “NORTH”

It could happen in the workflow on submit, but not sure how you would do this given its a random anything I am looking for?

Any pointers would be great?

Thanks in advance!


#2

Hey @StevenM,

The traditional coders way to evaluate strings in a case insensitive manner is to convert everything to lower case values. You can use that here to compare the typed text, against the value of the search box.

Start with an expression element from the Toolbox plugin to make the value lowercase. I’m doing this in an expression because in a later step when I compare the two values, Bubble won’t let me use the :lowercase modifier on both sides of the equation.

Then in your workflow or actions use the following to trigger for existing values (regardless of case.) Example here to show an alert, and I’m only triggering if the user is entering a new value:

Or the opposite to trigger for new values:

Unfortunately, we can’t do a lowercase comparison in a search constraint in Bubble, so this means we’ll be pulling the entire dataset over and comparing in a filter. You’ll just have to see if this works well for you dataset.

EDIT: If the use of a filter isn’t performant, then you could always store a second version of your value, always as lowercase. That way you can easily do a lowercase comparison using a search constraint.



Looking to accelerate your app development?

Let me turn
:thinking: :tired_face: :confounded:

into
:grinning: :sunglasses: :woman_student:

Development through Coaching at https://uniqueideas.com or schedule a free intro session :gift:

Ken Truesdale
LinkedIn


Ensuring case sensitive unique usernames with only specific characters
#3

Thanks @mebeingken I will give this a try and report back, appreciate your time in laying out a solution!


#4

Thanks @mebeingken this worked a treat! I had to make a few changes in the work-flow but because its not pulling in a large list to compare and probably wont be greater than a few hundred the performance is not effected.