I need Bubble to take two lists of things and return the entries that are in both lists. So I believe I should use Intersect with for this usecase. However, then the initial value on page load is empty. Doesn anyone have a workaround for this?
Are you setting that as the initial content of an input? Or as the data source for a repeating group? In either case if your results are coming back empty because one of the lists initial value had no items in it then you need to create a workflow that sets the state of an element that is of the type you need and is a list. Any time either list changes then run the workflow to set the state of that list. Finally, use the custom state in place of wherever you are putting “List 1:intersect with List 2”.
It’s indeed for a RG. However, I want the list of ‘tags’ to be empty by default/page load. And then users can select multiple tags and when atleast one of those tags match a thing, then the RGshould filter those. So more like the oppisite of ‘contains list’.
Ok. So as users select ‘tag’ run a workflow that adds that tag to a custom state that is a list of tags. Then next action would be to set the state of your custom state “matches” that is a list of (I’m assuming texts). Set that state to be List of things :intersect with List of tags. And on your RG you can have a conditional that says if List of matches: first item is not empty then that is your data source.
I handle this by putting a conditional in front of my advanced filter intersect function. If “Input” is the list of things you are searching on, then in the advanced filter I say… Input:count is 0 or Input intersect with…
When your input list is empty, then the condition “passes” and all items are shown. But if the input list has something in it, then it goes onto the second condition and does the intersect.
Use “OR” instead of “AND”. The advanced filter is checking each result from your search and asking if it passes the test. So if the input is empty, every entry “passes” the first part of the expression.
Note that when Bubble evaluates an expression it is efficient in that since the first part of the expression is a yes, it sees no need in evaluating the second (the intersect). So it will only evaluate the second part of the expression if the first part is a no.