Forum Academy Marketplace Showcase Pricing Features

[Solved] Relational Data

Hi There,

I am new to Bubble and still trying to wrap my head around how to relate data within Bubble. I have a client intake page that any number of clients can access to input their details (name, phone, email, address, etc…) that data is saved in a thing called client. After they have input their info and click “next”, they are taken to a different page where they are given a questionnaire. The answers to their questionnaire is saved in a thing called questionnaire. Each client only has 1 questionnaire which can then be edited by an admin later…My question is how do I relate the client who is entering the data to the questionnaire? so that after they input their client info, that info is linked with the questionnaire they are filling out?

Thanks in advance,

Matt

1 Like

There are several ways to do this:

If your clients are also creating user accounts (with login/password): You can add a field to both type client and type questionnaire that is a field type user and save the current user to each of those things when they get created. You’ll be able to retrieve them via those fields.

If your clients are not logged in users: add a field (type client) to your questionnaire data type and a field (type questionnaire) to your client data type. Then make the questionnaire page type “client”. When the user clicks whatever button it is that navigates to the questionnaire page, send the newly created client entry data to that page as well. Then when you click the button that creates the questionnaire, save current page’s client to the questionnaire’s client field AND make a change to current page’s client > save newly created questionnaire to questionnaire field. Now both are related to each other.

You can also achieve without having a page be a specific data type by sending a URL parameter, but let me know of the above makes sense and/or works for what you need.

6 Likes

YES! Thank you so much @romanmg that worked perfectly. I would also like to understand sending a URL parameter and which is better practice? I am very new to bubble and there is not very much training so any knowledge I can soak up is helpful.

Thanks again,

Matt

Awesome! Glad it worked out.

Sending a URL parameter would be a different route if you didn’t want to set the page to a specific data type. If for whatever reason your questionnaire page would have been more efficient being type questionnaire or type user or something else, then we would have simply sent that new client data via different means - the URL.

To do that, instead of sending page data, when selecting which page to navigate to in your workflow, you have the option to “send more parameters to the page.” You’ll be prompted to enter a key (whatever you want) and the value for that key (again whatever you want and this can be dynamic).

Example:

Key = “client” Key Value = “result of step 1’s create a new client”
In this case the unique id of that new client entry is sent to the questionnaire page. You’ll see your parameter in the URL as “client=uniqueid” at the end of the URL string.

Then to retrieve this data on your questionnaire page, on the same workflow that creates a new questionnaire, you’d still have that client field, but the value is “get ? parameter from page URL” (at the bottom of your dynamic options list) - select that, click on it again to bring up the parameter name input, and type in the parameter you want, in this case “client” - now, when the questionnaire is created, it knows that the value of that client field equals the client key in the URL.

Sending URL parameters offers a lot of flexibility because it’s really dynamic and you can do multiple parameters. Does this make sense?

EDIT: I think both routes are no more or less efficient - it’s hard to say because I’m not sure what the rest of your page structure or workflows are like and overall goals, but they require about the same amount of effort in my opinion.

3 Likes

Wanted to re-open this thread because I am trying to do the same thing, but with a native app.

The user enters in the title of their list- lets say Groceries, in an input field that auto populates the results in a repeating group. Then they can click on this newly created Grocery list, that displays another input field where they can add items that they need to shop for via an input field. The newly created grocery items are displayed in another repeating group.

So in essence this is what should be displayed…

Grocery list:

  • Sugar

  • Milk

  • Bread

Holiday shopping list

  • Games

  • Toys

  • Sweater

So I need to understand how to relate these items to each other.

Adding more notes:
The Grocery list is setup as one Database Type

The items to add to this “List” is setup as another Database Type

Sounds like the best structure is:

Your data type is Grocery List and within that type you have a text field for the list of grocery items - remember to make this field a list.

A new data entry is created when the user enters in the title to create it. Then the next input field is for adding grocery items - in the workflows, you’d “make a change” to the Grocery List you just created and for the items field, “add” this input’s value.

I don’t think you need your items to be a separate database type unless you’re doing a lot more with them. You’ll still be able to display the items in a repeating group if you wanted - the source is simply the grocery list’s items and each cell is each item. Does this answer your question?

Thanks for the suggestions. So I was able to get what I want to a point, but I need the multi list items to display in each row of a repeating group.

Once in their own separate row, I can then add a check box to delete an item.

Adding an update:

So I figured out how to separate each multi-line- add join with to the “line break” to the text thing in the repeating group row.

Now, one last thing…One I click on each “Grocery List”, it shows the same “items”. So I have to figure this out.

Your repeating group source should just be the list of items and each item should be on its own row. That way you can manipulate each item individually by “current cell”.

As for which grocery list to display - it’s all in how your set your source. If it’s by user, set a constraint on the search for grocery lists > created by = current user. Or if it’s something that you can reference on the page like a group that has its type set as grocery list and displays the content from what was just created… depends on the flow for your users, but it’s all in the source of where that RG is getting its list.