Setting up a default, if not ..

Options

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

  • Cameron B
    Cameron B Member, Administrator

    ADMIN

    Options

    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 our device 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 say device.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 this device.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 your device.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 :)

  • Antonio Duenweg
    Options

    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

  • Cameron B
    Cameron B Member, Administrator

    ADMIN

    Options

    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?