Better way to search RGs

I have built a search for my repeating group but its getting complicated. It works but there must be a better way.

I have 4 fields that can be searched. You can search as many as you want to. There are 15 possible search combinations (I think).

Is there a way to build this that doesn’t require 15 different combinations?

The data consists of financial transactions. The fields being searched can be:
Payee - text
Date - will be a range
Bank - text
Category - text

I’m aware of the search any field but that can give me unwanted results. Also, I prefer to have each search provide instant results as they are being searched - as opposed to asking user to pick the ones they want then hit search. And I want everything presented when there is no search.

I think what you’re describing can be achieved with a single search condition in your RG data source.

  1. Create a custom state for each field (or “constraint”). I think you will need 5 custom states as you will need 2 for the date range.
  2. For each search field, use workflows to update the relevant custom state(s).
  3. Within your single RG data source, create a different constraint for each of the 5 fields using the relevant custom state.
  4. Within the RG data source, check the box “ignore empty constraints”.

Here is a similar example from my app:

hey presto!

I was heading down that path but not with custom states. Why does custom states work but not the input elements data (or empty data) not work (which is what I’m finding out)?

I’m not able to create a workflow using date picker change. I’m using airdate picker plugin. I guess I need to use the built in date picker as it can be used in a workflow - when input changes.

Use the when “An input’s value is changed”.

Screen Shot 2019-12-29 at 1.08.22 PM

The resultant workflow will look something like:

Yep. The date input element plugin didnt allow for that. Not sure why. The bubble date picker works though.

There’s no reason to use custom states. The Input elements will work just fine and your search will update automatically as the input value changes.

Can you expand on how that would work?

Set your search up as described by @SerPounce but set your constraints to the value of the relevant input rather than a custom state.

Make sure Ignore empty constraints is checked.

I can go in more detail later if needed. Watching football with my kid at the moment :slight_smile:

I have now tried it both of your ways. Neither is working.
I tried with and without the custom states for both the datasource search and the filter on that search. Not sure what I’m doing wrong. I know doing with the RGs constraints it will work but thats a lot of constraints. The dates work but the text wont.

So I have found the problem but not sure why its a problem.

It relates to the field accounts. I think the issue is that this field is from another type. I have a type Accounts (ie checking, savings, etc). Each transaction (the type I’m searching) has an account.
For whatever reason, the RG wont show transactions until I pick an account.

I want the search of accounts to be able to select 1 or multiples. This does not work when I use the multiple selector (bubble plugin). If I use a drop down or a regular search it works but then the user can only search one account at a time.

@mjrudolphi You need a single search with no additional filters.

Your RG data source should be Do a search for transactions with 5 constraints:

Payee contains input Payee’s value
Date => datepickerMinimum’s value
Date =< datepickerMaximum’s value
Bank contains input Bank’s value
Category contains input Category’s value

Check ignore empty constraints. This will make the search ignore any filters that aren’t being used.

Obviously I’m making up input names here but unless your data is different than what you put in the OP, that will work.

@eli Yes that is what I have done but it does not like the Bank contains. Meaning, the RG wont show any results until I search at least one Bank value. Could that be due to the link between the transactions and Bank in my dataset you think?

I cant do Bank “contains” - only allows =, <>, is in, isnt in, …

That’s makes all the difference as it’s not a simple text field.

If you want the user to be able to select multiple account types you’ll have to play around with the ‘is in’ operator. I.e. Bank is in multidropdownBanks values.

OK finally got it. Here is what I had to do. On page open set the custom state for accounts to be all of them. Then as the search changes I update that state. If the multisearch box is empty I put the state back to all accounts.

Thanks eli and SerPounce for helping me think through this. Just goes to show there is an answer out there if you poke at it long enough.

1 Like

@mjrudolphi Ok, so point one, this is a very standard search setup but the data structure you outlined in your initial post was wrong. Not only was your Bank field NOT a simple text, it was also a list. And, on top of that, a list of Things that you wanted to be able to filter by multiple selections. Had you described it accurately the answer would have been very simple to give.

I enjoy helping people on this forum but it is frustrating to take personal time to answer someone’s question only to discover the question they asked was flawed.

Point two, custom states. It seems the answer given to every question on the forum anymore is custom states.

Are custom states useful? Absolutely, they are vital to a well designed app but why use a custom state when you don’t need to. For example, if you are filtering a search and want to push a button to apply the filters, sure, you can use custom states there. Though generally using a URL parameter for that scenario is better as it allows you to refresh the page and keep your search parameters intact.

But if you are wanting your search to update immediately without requiring a search button to be clicked, custom states are simply duplicate data that are adding extra workflows to your app.

So let’s look at your setup and see if we can simplify it. You have a multidropdown field that contains the exact items you are adding to your custom state. Only you are running a workflow on page load that is setting the list of things in your custom state because otherwise your search returns nothing.

On top of that, you have a couple of additional workflows that reset the data in the custom state on an input change.

How might that be setup differently? How could that be easier to maintain and cause less impact on performance?

Suppose we use a conditional on our Repeating Group to change the data source. Hmmmm…

See, as long as you have a constraint in your search on the Bank field your search will not return results unless the Bank filter contains data. However, if you DON’T have a constraint on the Bank field, the search will return results for every Bank option.

Suppose our main search on the Repeating Group just left out the Bank field. Like it doesn’t matter, we don’t care, we don’t want our results filtered by the Bank field in any way at all.

Then, on a conditional we can say, “Hey Bubble, if the multidropdown Bank filter’s value is not empty then change the data source to a search that contains a constraint on the Bank field.” Right?

Here’s a conditional I have in a live app that does exactly this:

So if there is an option selected in the multidropdownBank filter, our search will include the Bank field as a constraint and we will get results because the Bank filter has a selection made.

If the Bank filter is empty, our search will NOT include the Bank field as a constraint and still return results.

And doing this we eliminate the maintenance of a Custom State and at least three workflows.

Simple right?

I didnt mean to take you away from your personal time for my flawed question. However, it is a forum and it is going to be full of flaws and inaccuracies. I have only been using Bubble for a few weeks and I’m not a developer. Never built anything like this in my life. I’m an accountant by trade. You have been helpful and I thanked you for that help. I appreciate that you do take time to review the forum to help others (that is very nice). I assume you do it because you enjoy helping others.

From what I gather from my limited experience with bubble, there are many ways to achieve the end result you are wanting ( kind of like life itself). Are some ways more “right” than others? Perhaps.

Thanks again for your input. You have been very helpful.

I posted in the showcase thread for that plugin in the past on how to make a workflow…tried searching the forum for it but it seems like it got deleted for some reason…anyway, serpounce was correct in pointing out how to do the workflow

You need to create the conditional workflow ( ie. do when )

You are right, there are typically multiple ways to do the same thing in Bubble. Some are definitely more performant than others and it bothers me to see methods recommended that can cause unnecessary performance issues.

I’m a former marketer and before that I spent my life in the construction industry so welcome to Bubble from another accidental developer :slight_smile: It’s a great tool!

1 Like

Yes - you actually gave me the idea to go back and redo some functionality. I was using a user selected check mark in a repeating group to identify transactions to edit. I had the check mark update the transaction field I created in the data which was really slowing down the app. So I instead used a custom state to identify the transactions to edit. Much smoother.

1 Like