I have a site I am building and I am trying to query city and state into one text field like Seattle, WA. Every time, I write Seattle and put the comma the query reject my demand; and when I add the state it does not work at all. When I type the city and space; the query disappear.
I tried different function of split, it is not working.
CountryName and City are in two different table in the database.
In the data picker of the condition, I can only select the $Get.location and there is no other array I can select in the filter. I am sure I am doing something wrong or I am not seeing.
If there is anyone who can outline the step for me it will be very useful.
Not near a computer so cant actually check but from memory.
Use a set value stage to create the array
I.e. set value params = $_GET.searchstring.split(" ")
Your two strings will be in params[0] and params[1]
You may have to deal with what to do if only one word and space sent as referencing an undefined array parameter may cause an error. This should involve some if conditions and string checking, sure you can do that.
I tried to write the step and see if it will work. It is not. I even try to see with @TomD method too. I believe I am missing some step here. I am not sure which part.
Does it work if you don't include the comma? You can strip out unwanted characters (eg commas) before using them in the query. If this doesn't solve the problem, start by simplifying your query and getting it to work, before making it more complicated. The query you showed at the beginnig of this thread looks more complicated than necessary.
Yes, the query work if the comma is not there. However, it works only with one keyword if I try to write seattle, Wa it doesn’t work.
The input value does not give the result when I try to type two keywords from two different table.
Note: City has its own table and State has its own table. sometimes, user research for city and state by typing.
The simple query work with only one word but not with two words.
Typing the city and the state doesn’t work. I can only type the city.
The query alone work without text filter. However, user might have want to look for the city and state.
When I type the City alone it works. When I type the State alone it works also. But when I try to type City and State. It does not work.
Not sure why your previous version did not work but try starting your server action with something like this to extract the two values of city and state (which you can examine if necessary via app connect server action success event) NOTE this is cased on a space between, NOT a comma
Then use LocationCity CONTAINS {{city}} AND regionName CONTAINS {{state}}
@Hyperbytes I had to restart the step of the query you showed me. I guess the query was not showing because I wrote Get.location.split(’’’) instead of Get.location.split(" "). There was no space in the first get.
It is working now. However, I have one more issue;
When I type city like "Miami Florida "- it works.
However: When I type city “Miami Beach” it does not work.
Note: The first word works fine with the space but when I type something extra like Miami Beach. It does not.
I tried with Los Angeles too it is not working. When the city is two words the filter does not show. However, when it is only one word it works.
Thank you again for the first step. Thank you a lot.
Is there any solution you can give me for you the city with two words issue.
Yes, as a space is the delimiter then if you add a two word city the seconds word will be interpreted as the state and the third word (the state) ignored.
Many ways off resolving this and as is normally the case, the best solutions are the most complicated. Perhaps the easiest is to use a comma as the delimiter rather than a space although i would also suggest you add the trim function to remove any spaces from the start and end of the split values in case someone enters Miami Beach, Florida or similar
I end up using this split: {{$_GET.location.trim().split(",")}}
Thank you for your help.
The split with separator comma allowed me to use two words with city and use the comma.
I can only write this way: “Miami Beach,Florida” I cannot write “Miami Beach, Florida” . The space after the comma stop the query from running As you stated.
It is not at far from what i was looking for. I really appreciate your help.