Forum Academy Marketplace Showcase Pricing Features

[SOLVED] Filter RG by more than one data source?

Hello again,

My question this time is this: I have a social page, and when you click send it will add that post to the RG (The social is it’s own Thing), I have the RG doing a search for social and sorting it in descending order. Would it be possible for me to also have it do a search for users and filter by who you have added as a friend?

Thanks!

Yes, you can change the data source of the repeating group using conditional formatting. For example, if you had two buttons: “Everyone” and “Friends”, you could set up two workflows:

“When Friends Button is clicked”
Element Actions --> Set State --> Element: Repeating Group Social --> (create a new custom state… Name: Current View, Type: Text, List: No), Value: Friends

“When Everyone Button is clicked”
Element Actions --> Set State --> Element: Repeating Group Social --> (Name: Current View), Value: Everyone

Then you’d set up a conditional statement within RepeatingGroup Social such as:
When RepeatingGroup Social’s Current View is “Friends”
Property to Change --> Data Source: Search for Socials (with the constraint that the Creator is in the Current User’s List of Friends)

You can then set up conditional formatting on the buttons which will change their style depending upon whether a User most recently clicked Friends or Everyone. For example, you could have the text in the Friends button bolded when RepeatingGroup Social’s Current View is “Friends”, or have the text in the Everyone Button bolded when RepeatingGroup’s Social’s Current View is “Everyone”. I’d also create an event in the workflow for ‘when page is loaded’ which sets the Current View state of RepeatingGroup Social to either “Friends” or “Everyone” depending upon which data source you’d like to show by default. :slight_smile:

1 Like

Okay I will give this a try later today and let you know if I have any issues.

Thanks! I actually like that feature of being able to switch between friends and everybody rather than being stuck with friends.

1 Like

Okay, the main issue I’m having is that the friend’s list is saved under type user and the RG is getting it’s data source from type social. When I try to sort by friends list it wants me to change the data source of the RG to type user.

Any Ideas on how I can fix this?

Ah, sorry about this @zornman45. I misread the part where said do a search for Users; I for some reason only thought you were changing the repeating group’s data source and adding a constraint. To display a repeating group of Users you will need to create a second repeating group. You can keep the Friends button, and then have the Users Repeating Group visible when the custom state’s value is “Friends”, and hidden when the custom state’s value is “Everyone” (and vice versa for the Social Repeating Group)

That’s okay, friend. I appreciate you helping me out!

I will give that a try in a little bit :slight_smile:

Awesome! Sounds great! :slight_smile:

Would you mind taking a few minutes to look at the way I have it set up? Doing the two RGs doesn’t work either. The issue I’m having is when a new post is created, it creates a new Thing of type social. So I can’t sort by type users and only display posts by friends because then the actual post doesn’t show up. Neither do the up/down votes.

Can you turn the app to not be in read-only mode temporarily and then I’ll set it up/explain how with screenshots?

Yes I will do that

It’s done

Great :slight_smile: I added the buttons/workflows. If you can login as a User with a friend who has posted it will display posts only created by Friends when you click the Friends button. To double-check is this what you were trying to achieve? I’ll go through the how-to if so, unless I am missing something?

1 Like

Yes that’s exactly what I wanted! Thank you so much.

1 Like

Awesome!! No problem at all! :blush: To explain, I created the buttons “Everyone” and “Friends”.

Then I set up the workflow for the Everyone Button:

And the workflow for the Friends Button:

Current View is the custom state (Type: Text, List No), of the RepeatingGroupSocial. The only values for this custom state are: “Everyone” or “Friends”.

*When the page is loaded, the value of the Current View custom state is set to “Everyone”.

And then this conditional formatting is added to the Repeating Group Social:

Here we’re just telling Bubble that when the value of Current View (custom state) is “Friends” --> property to change: Data Source --> Do a Search for Socials, with the search constraint that the Creator of the Social must be a User who is in the Current User’s Friends List.

And then we can change the conditional formatting on each of the buttons so that they change their coloring depending upon the state of Repeating Group Social:

And that’s it! :slight_smile: I also saw that when a new Social is created - you don’t need to have the fields ‘username’ and ‘profile pic’ within the Social data type, and can remove them from this workflow when ‘Post’ is clicked:

Instead, the dynamic data to display the Creator of the Social’s username or profile picture in the Repeating Group’s cells can be “Current cell’s Social’s Creator’s Username” and “Current cell’s Social’s Creator’s Profile Picture”. Since Each Social has a Creator by default (a User), you can dynamically display that information through that expression, without having to save it every time a User creates a new Social.

2 Likes

Thank you for the explanation. I was having a lot of trouble with this, now I understand how it works.

I really do appreciate all your help!

1 Like