Toggle Sorting in Repeating Group Search Results

Ok, I’ve all but abandoned hope on this, but it seems like there should be a simple way to do it. Building a simple app so that people can read and send letters to refugees detained by ICE. (check out our project at

I have a repeating group that produces a list of LETTERS that can be viewed. The List is filtered by Date_Received based on the Date Range Picker plug in.

I want a simple button that toggles between sorting the list based on Date_Received (primary field) and the author’s name which is Author’s Public_ID (secondary field)

I’ve tried several dozen approaches using custom state, but I just can’t figure out how to get the syntax right or something because the minute I set it up, the search completely breaks and either spits out a million looping errors or gives me nothing at all.

Help! I’m completely lost here.

PS: I set up the button with it’s own toggling custom states, but didn’t connect it to anything but itself. I just deleted all my other attempts cuz it was getting ugly.

Here’s a straightforward approach that should work well for you:

  • Create a custom state on the page. Let’s call it, say, “sort-order” and let’s make it a text field.
  • Let’s set the default value of this custom state to the value “date”
  • Then, let’s add 2 workflows. When a user clicks “Sort by Author” then set the value of “sort-order” to be “author” and when a user clicks “Sort by Date” then set the value to “date”
  • In the repeating group, let’s leave the data source blank.
  • Let’s also add 2 different conditions. The first, when the page’s sort-order is “date” then let’s set the data source equal to the search you want to run when it’s sorting by date. Second, let’s add similar logic for when the page’s sort-order is “author” then let’s set the data source equal to the search you want to run when it’s sorting by author.

That’s it. Let me know how it goes.


Thanks… I’ll give this a try tonight and report back

1 Like

Not quite. It’s having the same looping error when I hit Sort By Name


Can you share a screenshot of the search you’re using to set the data source?

Editor Link: otay-allies-exchange | Bubble Editor

I think there’s an issue because it’s a secondary field value? Or maybe, i just got the syntax wrong?

There’s a few things that aren’t quite right with this search. And, the good news is that creating the search that you want is much easier than your current logic.

First thing - you’re running into a circular reference because you’re referencing the current values for the repeating group (RG) to change the sort-order names to be displayed in the RG.

Second - it’s a good practice to add filters and sort-order within the “search for” rather than as separate items. While the logic works the same, by putting it in the “search for” your app will run the entire query on the server which is much faster.

So, the way I’d approach this is:

  • Start with: Search for Inside Letters. When you set-up the search, you’ll want to reference your database’s values for the Inside Letters.
  • Then, if you click on “Search for Inside Letters” you’ll notice a 2nd edit menu opens up on the left. This is where you’ll want to add filters and change the sort order. It’s better to include them here than in separate parameters.
  • For sort order, just select “Author’s public ID” – it doesn’t seem like you need to use dynamic value since your sorting by a value that’s already listed on each “Inside Letter” in your database.

Let me know how this works.

Thanks for taking time to help me through this!

Ok, sort order doesn’t give me the option of the Author’s public ID. The problem is, the way the data is set up, each Author has a public ID, and each letter has an Author. So the Author public ID field isn’t a field for the letter. (I set it up like that because some users need to see all the author’s information, but public users only get a first-name-plus-initial for privacy reasons.

Brainstorm: is there a way to mirror a field entry between two things. So, when a Letter is assigned an author, a Letter_Public_ID field automatically populates with the Author’s Public ID?

Okay. I believe you can use “Change which field…” as you were doing then. I hadn’t understood it was a separate table.

The one thing to do differently here, is the dynamic field name should probably be something like “Inside Letter’s Author’s Public_ID” – you don’t want to reference the RG here.

hmmm… it doesn’t give me that option…

Okay. I haven’t used “change which field…” in a sort for a long time so perhaps my instincts are wrong here. I’ll search the forums - what’s you’re trying to do seems straightforward enough.

1 Like

Thanks for this. Seriously. And it’s not super urgent if we need to come back tomorrow or later this week.

Here’s a link that has some good answers: Why is sorting a RG dynamically so difficult?

My pleasure. Happy to help.

Ok, i’ll follow up with that thread… doesn’t look like they posted a final solution, but I’ll comment over there and see if they landed on something workable.

It sounds there’s not a direct solution, but perhaps 2 indirect ones.

The 1st is simply to include the value on both tables. That eliminates the need to reference another table. This becomes easy to set-up, but adds 1 extra workflow for each time a user changes that value (since it’d need to be updated in 2 places).

The 2nd is to structure your database so that the parent-child relationships work. I doubt this is the way to go.

There may also be a way to search the Author’s Letters and then sort by Author’s name. Not quite sure - would have to try it out to know.

1 Like

Although that does seem to work ?

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