Hi,
I don’t understand how it works… the comparison text I try to use is grayed out.
-
I add a city through this form :
-
Here is the function to add the data to the DB :
-
Here is the DB copy :
What’s wrong ?
I’d like to prevent duplicates.
- So I added a condition :
But I can’t compare the Cities’name to the search ; I don’t understand how it works.
I just want to check if the city doesn’t already exists.
Thanks for your help !
Thomas
Why don’t you check if the city exists prior to DB update? Then you won’t have to deal with this problem and will be better for UX.
Thanks ! How do you that ? I haven’t been able to understand and find online how I can check if the value exists in the DB outside of the process I just described before. If you have the link to a tutorial it would help a lot
Add a text element that says “This city already exists”.
Add a workflow event “when an input’s value is changed” and in the only when area add “do a search for” the city.
Then add an action that shows the text element.
Make your button not clickable when the text element is visible.
Thanks for your feedback !
- I’ve created the text field
- I went into Workflow tab and I’ve added an event “when an input’s value is changed”
- I selected for “Element” the “Searchbox”
- Then I wanted to set up the “Only when” but I’m facing the same problem as explained at top of my post : I don’t know how to configure properly this part…
So my method is :
- “Only when”
- “Search for Cities name” (so I imagine it returns an array ?)
- Then I check if this array contains “This SearchBox’s value” (which is the name of the city, since when I save the city I use the same variable construction)
Thanks in advance
The 2 types you are comparing must be the same. So you’ll need to have the search for cities return text values.
Hi,
Thanks for your feedback. There are several cities in my database ; I need to compare my search with the database to see if it contains the searched city.
I can’t compare the searched city to 1 value (string) only. I should check if the db (like an array) contains it.
I don’t understand your solution of comparing same kinds of values since there is an array (db) and a text (str in search)
I’m sure my function is good. I don’t understand how it can be false. I need more help.
- In the “Only when” condition I have put “Search for Cities” (The Type is Cities and the constraint is “name”)
- Then I put “contains” and I selected “This SearchBox’s value”
So my statement is “search in the cities list if the searchbox’s value already exist as a name”. The “contains” condition is made for this kind of purpose.
Thanks in advance,
Thomas
I found the solution. Finally.
So the best seems to be this:
- In Workflow clicks on Click here to add an event
- Select the Elements > An element is clicked
- Then in the window select for Element the Button Validate the city
- Add a Only when condition which starts with Do a search for
- In the side window select as Type Cities ; don’t add any constraint
- Click on More… in the Only when and select 's name
- Click on More… in the Only when and select doesn’t contain
- Click on More… in the Only when and select SearchBox Search a city…
- Click on More… in the Only when and select 's value
- Click on More… in the Only when and select 's formatted address
Then create Steps in your workflow:
- Create a new City (as shown at the beginning of this FAQ post) but for name have SearchBox Search a city…'s value’s formatted address instead of SearchBox Search a city…'s value
- Add a clear inputs if you’d like
2 Likes
Your solution works like a charm.
The problem now is, how do I tell to the user that it hasn’t been created because it was duplicated?
Thanks!
Use an alert to communicate that , if search for cities contain search-box value, show an alert that the searchbox name already exists .