Forum Academy Marketplace Showcase Pricing Features

How do I set a Constraint when the field is not in the table you are searching on

I have a simple table as so:

and I want to display a repeating group that displays all the factories that make paint.
However, the constraint field will not let me set makes = “paint”. Why not? I’ve tried a few other settings in that constraint area but they are all failing.

Link to page: https://bubble.io/page?type=page&name=search_issue&id=testsandstuff&tab=tabs-1

Because Paint is a value within the Stuff type. So your constraint needs to be Makes = Search for Stuff :first item, where Search for Stuff has a constraint of Type = Paint

I updated for you. Check it out.

2 Likes

Awesome ta. I’m not really understanding :first item. I thought it was maybe because Paint is the first entry in my Stuffs table but :last item also returns Paint results and the last entry in my Stuffs table is Nuts, not Paint.

Then I thought :first item was saying ‘the first item you come across in the Factory table’ (and you could change the sort order as well if you wanted to) but :first item and :last item return both Paint results in the same order.

Why do I need ‘:first item’ and what is it doing?

Jess

You need first item because a “Search for” something in your database will return a list value, so you need to convert it to a single item value. What this expression is saying is to return the first Stuff thing that matches the search with constraints. We know that one Stuff thing will ever match type = Paint, so whether it’s first or last item… Only one record matches. You’re right, you could also use last item here.

Your Make field is actually a Stuff Thing, so this expression is saying … the source of the repeating group is a list of all Factories whose Stuff is the first Stuff record to have Paint as its Type. Because you have a constraints on the Search for Stuff, it’s going to ignore any other Types (eg Nuts), so it’s taking the first item of only Stuffs that are Type = Paint

Ahhhhhhhhhhhhhh. I needed that full explanation before my brain got it! Thanks!

1 Like

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