Forum Academy Marketplace Showcase Pricing Features

[Solved] Need help with types and fields

Hi all. Firstly I am loving Bubble and all I have been able to achieve so far but I am stuck on one aspect

I am attempting to record vehicle based trips. Each Trip has at least one or two Vehicles - an RV towing a car for example. Each vehicle has a start odometer and regularly recorded odometer readings to be able to calculate distance traveled within that Trip

I therefore have a Type called Trips and a Type called Vehicles.
Fields - Trip Name
- Destination
- Start Date
- List of Vehicles

Type - Vehicles
Fields - Vehicle Name
- Make
- Model etc etc

I can save trips to the database with its list of vehicles OK. I am now really struggling with where to nest the start odometer and regular odometer records for each vehicle on the trip. The odometer of course is related to its Vehicle. Should odometer be a type or its own and then nested as a list either in Trips or Vehicles, or just a field within either Trips or Vehicles. How would I then save them to the database
It should be noted that as well as each trip having multiple vehicles, each vehicle can be used for multiple trips.
I hope someone can stop my brain going round and round in cirlces

Try creating one more type ex: “trip details” which is linked to both Trips and Vehicles.

therefore it will now be 3 tables/types :

2: Vehicle

3:Trip Details

the Trip ID and Vehicle number must be considered from Trips and Vehicle table/type respectively.

1 Like

I would also be tempted to have a list on both vehicle and trip of trip details, to make your queries easier.

So you can do “Vehicle’s Trip’s odometer reading” for example … Rather than having to link it via a search using the registration.

Embedding tends to be easier than relational style lookups.


I saw your recommendation to do this on a post a few months ago, and it has saved me so much time on the app I’m working on. Highly recommended.

Thanks @NigelG and @samuel for your advice. I have built the new type .

To be able to save data to this new type I am now wanting to build a popup for the user to enter the odometer data. The user will first have to choose which vehicle to enter the odometer for and I thought either a repeating group or dropdown with just the choices of the vehicles for that trip only, but I am struggling again. What is the correct “type of content” and “data source” for the Popup and repeating group. I have tried all sorts of combinations but either I get all vehicles in the database or none. I need just the vehicles list for the selected trip (I do also have a list of vehicles in my trips type and a list of trips in my vehicle type)

Hope you can help

I think you are making life harder for yourself there.

Instead of “Trip Id” and “Trip Vehicle Id” as text type fields, have them of type “Trip” and “Vehicle”.

Also I am not sure the “List of Trips” and “List of Vehicles” are that helpful on there. If you move them to Vehicle and Trip respectively, you can do much the same thing (i.e. “a list of trips this vehicle has been on” and “a list of vehicles on this trip”).

Your popup should probably just be “Trip” - that way you can have the drop down as type “vehicle” on the Trip’s Vehicles list.

Really the best way to get this working is to make you app public, or copy the relevant part to a public app. It makes it a lot easier to see what you are doing :slight_smile:

1 Like

Thanks again @NigelG I was probably over complicating things. Have removed a few data types as suggested but still can not work it out. Here is a link to the main page I am having problems with. The page is accommodation and the popup is Mileage

OK, so I think what you need to do is set the data source on the popup to the Trip Drop Down. I made the change on the element.

Then your Dropdown’s values are right, it will have the vehilces for the trip.

I thought this too @NigelG but that gives me no vehicles in the dropdown. The app is currently logged in with user named “test” who has one trip called “test” with a vehicle called “test”. If you go to the accommodation page and select the trip called “test”, then add an accommodation and select the enter mileage detail button the dropdown in the new popup is empty.

Just looking further at this @NigelG. Is it something to do with the data I am sending to the popup in the workflow when opening the popup. I have started playing this this and now have “lorum ipsum” coming up in the vehicle dropdown so this has made some difference but not quite right yet

I’m looking at your workflows right now, and you have an error of types on your Accommodation page. The page is expecting to be a TRIP, but you are trying to send a USER to it. I’m having a tough time understanding how you intend your UI to work, which is preventing me from giving you some solid direction. The way it’s set up right now, you have a Slidebarmenu that is in the main app header. There’s an option for Accommodation in that menu. Accommodation looks like it expects data about one specific trip, but in your current setup, there’s no way for the page to know which specific trip it’s looking for.

Could you do a brief walkthrough of how you imagine this working?

Thanks for your help Andrew. I was just playing with the slidebar so it is not really set up yet. Yes you are correct that accommodation is about one specific trip. Basically a user enters data about a trip (trip name and start date) and chooses a vehicle (or two) from their database which they are taking on this trip. They then enter the odometer reading of each vehicle at the start of the trip (although I have not worked out how to save this odometer to the database yet). A trip can be anything from one night away to many months or years on the road. Within each trip there is accommodation, expenses, journal entries (I haven’t done expenses or journal entries yet). So they enter a new accommodation which records such fields as first night, last night and cost, which campsite they stayed at and then if they choose they can enter the odometer reading for each vehicle for that day to calculate how far they have traveled in each vehicle that day and on the entire trip so far. If they have not traveled that day they can choose not to enter an odometer reading in that accommodation entry

Hope this helps

Ah ok, I see. I think what’s throwing me off is that the menu for accommodation is in the slidebar menu, which is in the main nav area of the app, not in the page area. I’ll take a few minutes when I have some time today to poke around, if someone else doesn’t jump in there first. Thanks for the clarification!

A few issues …

Firstly …

Reset Relevant Inputs is getting rid of the value in your dropdown.

But the “Display Data in Popup” was using the Parent’s Trip, which isn’t set.

I have changed the Display to use the Trip in the Dropdown. And it now seems to work.

It is a little complex, but happy to work with you to get it on the right track :slight_smile:


Wow @NigelG. Thank you so much. This is awesome - I came up with the correct vehicles on the trip. Your suggestions makes so much sense. I am very new at all this but I am finding with Bubble it is all so logical. But if you miss those tiny bits (that sometimes you don’t understand yet) it has a big impact. This tiny bit of info has gone a very long way to helping me understand some other things I am missing also.

I may have a few more questions but I will take this away, play with it some more then ask you a bit more if that is OK

1 Like

Thanks @NigelG - I have now played with this and can now save all vehicles and odometer readings and even calculate distance traveled between entries. Thanks so much for all your help