Combining repeating groups

Hi guys. I hope you can help me as I’ve been pulling my hair out over this one for 2 days now and need to ask for help now. I think I’m being dumb because it surely has to be simple…

I have two repeating groups.
Each one contains some simple data from other areas of my database.
Although different data types, they have some fields in common such as company name & email.

I simply want to combine them all into a simple list that will contain one unified list of all names & emails. It will be used as a basic contact list, either for sending emails to or exporting as CSV.

The attached image may help visualise more clearly.

Thank you
Dale

One option would be to create a new datatype (i.e. Contact) to use as the content type for the repeating group, that links to either of the two existing datatypes (Label and Publisher).

Then you can use conditionals on the data inside the cell, depending on which of the two datatypes the cells Contact links to, and display the appropriate data based on that.

Thank you for replying. I tried to understand what you are saying but unfortunately I am not able to grasp it. Could you please elaborate on this further? Please note that while i currently have 2 datatypes for the example, in reality there will be many more. Likewise, the actual lists will be much larger than this example - so speed considerations appreciated too.
Cheers

Ok i have made some kind of progress using a simple element state (text), which contains text list of repeating group and data using “formatted as text” option. By doing this for each repeating group and using :append: it results in one single combined bulk list of text. Like a big CSV file. This is very fast and kinda exactly the end result i am looking for. great!

so now i just need to figure out how to parse the datadump back into separate items in order to use it.

If there is better suggestion then i am open to hearing it.

Many thanks again

A repeating group can only have a single content-type.

So it’s not possible to display different datatypes directly in the same repeating group.

So one option is to create a new datatype, that will be used as the content type of the repeating group, that has fields to link it to the various other datatypes that you want to show data from.

The RG content type will be that new datatype, and then you can use conditions within the RG elements to display the correct data (e.g. if current cell’s thing’s datatype A is not empty, then display the current cell’s thing’s datatype A’s Name etc.).

An alternative way, especially if you only need to display simple text data, is to set the RG content type to ‘text’ then set the data source to text fields from the various datatypes you want to display (using the ‘merged with’ operator). That won’t require the creation of any new datatypes, but it does make things a little more complex in terms of running actions on the cells data, or displaying things other than texts.

Alternatively you may just need to restructure your current datatypes a bit…

From what you’ve described (and I could be wrong as I don’t have much info to go on), both of the datatypes you mentioned in your original post have fields for company name and email, which I’m guessing are text fields. That makes it difficult to do what you’re trying to do here.

If that’s the case it would make more sense for those datatypes to have a field for Company (which is of type ‘Company’). That way the content type of your RG can simply be Company, and you can use ‘merged with’ to search for all the companies from within the various other datatypes, then display the company data inside the RG.

So it really depends on how your current database is set up and exactly what you’re trying to do, but I’d suggest double checking your current data structure and making sure it’s set up in the most efficient way to be able to access data as you need to.

Thanks for taking the time to explain. I wish i could say i understood everything there but unfortunately, a lot of that was over my head. I guess i am still firmly at newbie land.

For example, you say "set the RG content type to ‘text’ then set the data source to text fields from the various datatypes you want to display (using the ‘merged with’ operator)."

sounds simple, but everything i try turns red. Often the merge-with operator doesn’t even show at all. I do not know how to set those text fields , would that be using the “do a search for” command?

Screenshot 2022-01-23 at 20.24.47

I feel only a video conversation would help me get my head around this, so don’t feel obligated to reply as i do not want to take much more of your time.

Cheers
Dale

That datasource doesn’t make any sense (hence why it’s red)…

I’d suggest you take some time getting to grips with the basics of using Data in Bubble first (use the bubble manual, the tutorials, and this forum)…

I think the simplest AND mot useful way for you to proceed here will be with making sure your data structure is set up correctly for you to be able to access the company data directly from the other datatypes.

So, if you don’t already have it set up that way, make sure you add a Company field on each of the datatypes you’re working with.

Then you can use a RG to show a list of Companies, which you can get either by searching directly for them, or by accessing them from the other two datatypes.

ok i think what you are saying is that maybe instead of me setting database up like i currently have it where each section of the business has it’s own individual table & set of fields (like this:)

Datatype: Labels
fields: Name, Address, Contact, + labels specific fields

Datatype: Publishers
fields: Name, Address, Contact, + publishing specific fields

Datatype: Writers
fields: Name, Address, Contact, + musician specific fields

Datatype: Clients
fields: Name, Address, Contact, + client specific fields

(etc etc etc)

I should have set it up like this:

Datatype: Entities
fields: entities category (companies, clients, writers etc). + every other possible field.

this would result in one datatype with lots of redundant fields per entry, but ultimately more flexible in the long run.

Is this the kind of thing you mean?

Best

hey @asked111 ,
Here’s an example:

Object1:

Object2:

Combined Object:
Object1 (object1)
Object2 (object2)

Create a combined object each time object1 or object2 is created. If you have existing data, run an API workflow that creates a combined object for each object1 and object 2.

To show the combined data type in a repeating group: search for combined objects

  • create two groups within each cell of the repeating group. Each group is invisible on page load.
  • group1 is visible when the Combined Object’s object1 is not empty.
  • group 2 is visible when the Combined Object’s object2 is not empty.

bonus : to add filters, create new conditionals on group1 and group2 (when a custom state is group1, group 2 is invisible, etc).

Hope this is helpful!

1 Like

Hey guys, just an update on this to share my solution. Note that while this may be a solution for my particular use case at this time, i understand it may not be the ‘best practice’ approach., so forgive me. But for now, this is perfect for my needs.

This creates a list in the state variable, called ‘combinedlist’. very fast. I can perform all my current needs on this list such as sending emails or simply displaying it in a repeating group.

Many thanks for the suggestions

@adamhholmes

Want to ask, can we append the new records to the same RG but after calling API for next 10 records?
I mean i want to show previous 10 records and when reached to bottom of RG call another API which will give 10 more records for RG. And at that i just want to append those new 10 records to the previous one.

Right now what i’m doing is when reached to bottom of RG i call API but with increased no i.e. 20. Means first 10 records and new 10 records will be given by API. But i won’t find the option where i will append the new records only.

Thank you for your help.