Forum Academy Marketplace Showcase Pricing Features

How do I use multiple fields in a constraint?

I have a type called Place with 2 fields

LOCATION geographic address
MILES number

and a Search Box field with geographic addresses

In repeated group data source I want to search for all places where “place’s LOCATION is within MILES of Search Box’s value” but MILES field not showing in the drop down.

Hey @Bilal,

If you ever find that a certain constraint’s available options are not visible to you or you’ll need something a tad more complex to yield, always take a peek at the :filtered option for lists. A hidden gem in Bubble is the Advanced option for filters which can let you do some pretty crazy things. If you build constraints with Advanced, the terminology switches to use ‘This’ which is another way of saying ‘whatever thing the filter is looking at when it’s filtering’. You could tackle your constraint with an expression such as: This Place’s location distance from SearchBox A’s value <= This Place’s miles.

Take blockers as opportunities to learn more about neat and effective workarounds. :slight_smile:

1 Like

Thank you for the reply but as I understand filter option works on the client side which means all thousands of records will be downloaded on the client before the filter kicks off. Is that right?

That might be a good question for the Bubble team, though I believe the logic there is that everything is happening on the server side. You may be referring to a piece in the documentation that states filters are useful for having a query run once and be filtered as needed. Since you’re feeding the data source as filtered, everything is still handled off-site. If you stored the query result list in a state on-page and then used filtered for the data source, then that’s a different story. :slight_smile:

This is because it needs a number value, and only shows elements or other expressions as what it thinks can give a number. If you include, say, a slider control on the page, it would show up in the picker. Another option is a number field in a thing or custom state.

For flexibility, in addition to :filter that @iamsalar mentioned, you may find it useful to change the data source depending on certain values, by using the conditional tab.

MILES is a number. I will try your suggestion of changing data source by using conditional tab. Thanks @iamsalar and @mishav

This topic was automatically closed after 70 days. New replies are no longer allowed.