Setting up a default, if not ..
I have a live city app that's currently being used by users in City A. As the app expands, I need to add a new city, City B, to it. For new users, I've set up a mechanism using device IDs to automatically provide information related to City B upon selection.
However, I'm facing a challenge in setting up a default city. I want City A to be the default option if a user hasn't selected any city previously. Could you please assist me with this
Comments
-
Your device record has information that we can use. Something like
device.city
probably holds our city value, right?
This can be our argument. We want to check that ourdevice record
, for this query, has a city value. If it does, we want to do something. If it doesn't, we will do something else.
Within our conditional, we'll saydevice.city_id
=={your city #1 id here}
If this is true, we'll just go ahead and serve this value, right? Not an issue, we don't need to manipulate anything.
But if it's false, and thisdevice.city_id
!={your city #1 id here}
, we'll need to manipulate this value: we'll edit this record and add a new city.
This is the basis of how to proceed with this. Does that make sense?
To make this work for any and all cities, you can change yourdevice.city_id
to have a filter:is_null
, so that we can check if there is a value (not just city 1).Hope this helps :)
-
At the moment it is giving me all of the information from every city, I have missed a step and it seems is not filtering the information corresponding to each city
-
The conditional you originally set up, where one of the arguments is the id, will ensure that the device_id.city value equals the id within the argument. However, based on the screenshot above, this new logic is checking if the record of device's city column isn't null.
From there, you have to decide which city information to save to the user. On the device record, within their city value, you'll have to prove the right id to save. Does this make sense?
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback