How to create a Repeating Group with Elements ONLY IF a corresponding field is found in the database

I have an online review app where users can set up a public profile and choose websites they have profiles on. They then direct their customers to this public profile, where customers can leave reviews for them on popular sites like Google, Facebook, etc.

Here’s the thing: users may have profiles on some sites (say, Google and Facebook), but not on others (say, Yelp). So, if a user doesn’t have a profile on a certain site (and therefore, the URL in the database is blank), I don’t want that profile to show up.

At the moment, my solution looks like this:

As you can see, some profiles are active (Facebook), while others are greyed out. Obviously, this is not ideal.

Ideally, I want to create a repeating group with buttons that link to these profiles. If a URL is found in the database, a button will be created and will link to that profile; if the URL is not found in the database, the repeating group will move on to the next profile, look for a valid URL, create a button, etc.

The end result would be a list of buttons that match how many profiles the user has added to their account: if the user has 8 profiles, 8 buttons would appear in alphabetical order; if they only have 2 profiles, only 2 buttons would appear (with dynamic text and links, of course).

Is this possible?

1 Like

What does the data source of the repeating group look like right now, and how are the URL’s stored?

Without knowing your data structure, I’m going to suggest one for you that would make this easy.

User

  • List of Profiles (Profile, list)

Profile

  • User (User)
  • Platform (Platform)
  • URL (text)

Platform

  • Name (text)
  • Logo (image)
  • Color (text)

The user would create a separate Profile record for each platform he has a link for and add it to his list of Profiles. The repeating group’s source would be:

User’s list of Profiles’s Platforms : sorted by Name


Gaby at Coaching No Code Apps (formerly Coaching Bubble)

Courses & Products, Tutorials, Private Coaching, and High-level Development

Start Learning Today :mortar_board:

Right now, I only have a User data type with several fields for profile URLs (Facebook, Google, etc – they may be blank):

Is it possible to accomplish what I’m trying to within this structure? Can I search for non-empty URLs stored within a User and return only those values to a repeating group?

Yes, you can technically do it with this structure, but you’re creating more work for yourself. This will force you to create a bunch of conditions on the repeating group element for every combination. Not very scalable.

The repeating group will work do much more work for you if you make the structure more dynamic. There’s nothing wrong with expanding the data structure. It’ll give you a better base to start from. By storing the URLs in a separate data type, you’re allowing yourself to do things just like this RG. You can also let the User search and view reviews left for him with much more flexible filters.

1 Like

Got it – makes total sense. Right now, I have a page that lets the user input all of their URLs:

When the user clicks “Continue,” the workflow is as follows:

  • Create a new Profile for the user on Facebook ONLY IF the Facebook link is not empty
  • Create a new Profile for the user on Google ONLY IF the Facebook link is not empty
  • Same for Healthgrades, etc, etc…

I can create the profile in this workflow where the User=Current User and the URL=the value of the input field; however, I am having trouble finding the correct thing to put in the Platform field:

I already have a Platform for each service created in my live database (see screenshot below). Should I make the platform in the “Create a New Profile” workflow step the static text string “Facebook” since that will exactly match the title of the “Facebook” platform that already exists in my DB?

@romanmg would this work? Any ideas here?

Platform = Do a search for Platforms wehre Name = “Facebook” :first item

would be correct, you can’t just input a static text, instead you have to connect your existing db entry.

1 Like

Aha! I totally forgot I’d need to do a search. Thanks!

Do you have any idea why I would get the following error?

I have to get the current user from the URL’s path, but when I try to display their platforms, Bubble says this is “a different list of Platforms”?

Try to add a :first-item after the Search for User’s

Search for Users’:first item’s List of Profiles’s Platforms:sorted by Name

Same error, unfortunately:

@romanmg, since you proposed this data structure, any ideas? Have you ever seen this before?

Is it posible that you have created a Platform data type before, then deleted it, then created this new Platform type? It might be that you are crossing wires.

In any case, I’d suggest going about your URL input design a different way.

Use a repeating group instead of individual inputs for each platform. Type = Platform, Source = Search for Platforms (no filtering since this is the form the user is filling out). Each cell can show those elements dynamically:

current cell platform’s text (e.g. Facebook)

placeholder would be current cell platform’s base url (e.g. https://facebook.com/)

etc.

When the user changes the input, you create the Profile record for that Platform. Workflow would look like this:

When input’s value is changed (and input is not empty) > Create new Profile: Platform = Current cell’s platform / User = Current User / URL = input’s value

A second workflow in case they change their mind and delete one created… When input’s value is changed (and input is empty) > Delete Thing: Search for Profiles (Platform = Current cell’s Platform / User = Current User) :first item

Continue would just move them forward, but the changes to the inputs would do the saving (dynamically) since it’s within a repeating group cell. This way, you’ve consolidated it all down to one workflow to handle all platforms!

Awesome! This works perfectly for on-boarding, but I run into one minor problem when I try to display the list of Profiles in the app’s settings (users can update/delete these URLs later in their settings).

If a user doesn’t fill in every URL at signup…

…then their settings only shows the list of Profiles which they have created, while the rest are absent:

Is there a way for this repeating group in the app’s settings to show all platforms, including those that were “never created” at signup because their URLs were left blank? I just want to ensure users are able to add/modify URLs for all Profiles afterwards…

I understand that this might be hard/impossible since this repeating group is displaying a list of Profiles for a User, not an entire list of Platforms…

Not impossible! :smile: Just show all platforms like you do in onboarding instead of the user’s list of Platforms. Then, in the initial content of the input fields (for settings), set it to:

Search for Profiles [Platform = Current cell’s platform, User = Current User] :first item’s URL

This will allow anything saved to show up pre-filled. And anything not saved/created to be blank, allowing them to create from Settings as well.

1 Like

You’re a life-saver. THANK YOU!

1 Like

Ok, last question (I hope). I am getting one last error because I can’t effectively search for profiles that only belong to the user.

The page that needs to display the profile buttons in an RG is publicly-accessible and will be used by many people, none of whom will have an account; the user whose profile buttons I need to display is passed through from the page path (i.e. app.com/p/username). Because of this, the search field is expecting a User but is getting a username (text) instead:

Is there any way around this? Is the best way to just go back and set the User for each Profile equal to the Current User’s username rather than the Current User when these Profiles are created?

Well, normally, I’d make the entire page itself dynamic by giving it a content type of User and passing user data to the page, but I understand if you didn’t go that route to keep a cleaner URL.

You can still make the constraint work with another Search:

User= Search for Users [username=get path] : first item

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