How do I create a list with multiple fields instead of one?

HI all . . .

I’m creating a food tracking app for kidney stone prevention. (They suck.) I’m stuck on a specific way to save and restore a repeating group with multiple fields. The ugly starter page I’ve got is below. As per development examples, I create a set of elements which define a portion of a meal and calculate oxalates consumed, the nasty bits that make kidney stones appear. I want to have those persist in a list as per the code example of a shopping list, but lists appear to be single item things.

My assumption is that I need to create a table of menu items and a table of meals and get the intersection to populate the repeating group with them. However, I’m stuck on how to populate the repeating group and can’t find a good code example. The documentation is a bit light on this subject too.

Can you point me to a code example for this?

Mike

Hey @mbarnardca :slight_smile: Can you share a link to your app in the editor? This will give a better idea of how to do this with your data structure.

Sure, Faye. I think I set the privacy settings right to make this work.

Cheers, M

Great. Just to double-check, for the food entry portion, a User is supposed to enter:

-The Date
-What meal is this? question
-Food drink entry
-Adjustment percent

Then click Add to List. Once that button is clicked, the workflow should create a new Meal, which is then displayed in the repeating group below. Then the second action in the workflow should add that Meal to the Current User’s List of Meals (for example)?

Pretty close. A meal has a date, a type of meal and a set of items that make up the meal. Each item in the set will have the description of the item, the category of the item (although I will probably normalize that out in another iteration), the adjustment percentage and the adjusted mg of oxalates.

A meal would be, for example:

2016-11-28
Lunch
Szechuan noodles with BBQ pork (200 g), Pasta, 100%, 10
Hot and sour soup (240 ml), Soup, 100%, 7
Beer, bottle (345 ml), Beverage, 100%, 8

I’m assuming I have to create two tables, one with Meal and one with Food Items. When I create each Food Item, I would grab the Unique Identifier of the created Meal. By making new Things I would persist them and be able to use standard Join etc on them for other purposes.

I need the functionality of removal of an item from the set of Food Items obviously, and that seems to be more tied to the Repeating Group functionality. Maybe I’m wrong though and there’s an easier way to display that bit.

Thanks for your assistance! M

M, got it! Can you change your app to temporarily allow me to edit it? (It’s on read-only now). I can clone the homepage and adjust the workflows to show how this can be achieved. I’ll do a step-by-step as well. :slight_smile:

Done.

I’ve updated the Meal Item table with the relevant fields (based on the assumption that I was correct in needing two tables, which I think is correct for doing analytics later regardless).

Thanks!

M

No problem at all! :slight_smile: Can you test the ‘testing’ page in preview mode? Just want to make sure it’s working as you expected, or if there’s anything missing.

1 Like

Tested and it’s working very well! It’s the inverse of what I expected, which might be just the way that bubbles thinks about relationships as opposed to anything else. It’s not clearly a relational database, but a bit more like an old Pick hierarchical database, at least in terms of links between tables. I was able to build a quick display of meals and then one of food items, so it’s clear that the links work from the interface.

Much appreciated!

M

1 Like

My pleasure! Glad to hear you got it working in the way that you needed, M! :slight_smile: