Hi guys,
My app is to create a Job and then add Invoices to that Job. I have a Job and Invoice data type. I never know if the Invoice page should be of content type Job, or Invoice?
To get set up I am just doing a test to create an invoice (only saving Job’s unique ID and a dummy word for the test) and then I want to display the dummy word later to check it worked.
First step is to create the Invoice, this works and saves to the Invoice data type with both the Job and dummy word to the DB.
This data is displayed on a job-invoices group.
I have linked the cell to the create-invoice page where I want to see the Dummy word. This is to simulate if a user wanted to edit their invoice.
But the Dummy word doesn’t show when viewed in Preview?
Presumably there’s no data to show (my guess would be that the job you’re referring to doesn’t have an invoice).
There’s no enough info here to say (so feel free to share an editor link), - have you checked the data exists properly in the database?
Also, I’m not sure why you’re referring to the invoice’s Job, and then back to the Job’s invoice? Rather than just referring to the invoice? But I’m not sure that has anything to do with why no data is showing.
Hey Adam, thanks for the input. There is data which should be displaying so it should be a simple case of displaying it?
The reason I can’t refer directly to the invoice is because the invoice must refer to a ‘Job’, so the page to create an invoice has a data source of Job. This is the database set up you recommended to me in a earlier post when I posted a test website!
Here’s a link to view - note: ‘job-invoices’ and ‘create-invoice’ are the pages in question. The button to create an invoice is found in the top right on the header ‘FG top nav LoggedIn’;
This is the basic architecture. All of these are groups (single page app) and they all have a Job data source so that the invoices are linked to their parent Job.
But none of the Jobs in your database have any invoices - so of course nothing will display (there’s nothing to display)
But the invoice’s do have a Job, so I thought I could refer to the Invoice’s Job?
But you’re referring to the Job’s Invoice, not the Invoice’s Job
hmm, let me just change this … ah yes, I am forced to refer to the Job because the page is a Job data source. I can’t make it an Invoice data source or that cause other issues. I think I am back to the same issue and before!
Yes, what you’re doing here doesn’t make much sense…
I am forced to refer to the Job because the page is a Job data source
I thought this was a single page app?..
I don’t see why you need to refer to the Job at all in order to edit the invoice?.. just refer to the invoice (this should be even easier if you’re using a single page app).
Alternatively, if you really need to refer to the Invoice’s Job’s Invoice (which doesn’t make much sense) then just make sure you connect the Invoice to the Job via a workflow…
Although surely that should be a list of invoices, rather than a single invoice? no?..
Yes, sorry I meant ‘group’, not page.
I literally have no choice, Bubble gives me the option to refer to Job but not Invoice.
Because each Job can have multiple invoices then I need each invoice to be linked to it’s parent Job. Admittedly, I only envision 3 or 4 invoices per Job so I didn’t feel a ‘List’ was necessary.
This is the same issue you helped me with last week and in the solution we had the create-invoice page have a Job data source. This successfully saved the Invoice to the database but, as with this one, the Invoice refers to the Job but not the other way around so I can not refer to ‘Job’s Invoice’. This causes issues when I am trying to display data on a page with data source of Job.
One idea I had was to have a separate clone of the create-invoice page dedicated to editing, then I could make that an Invoice data source.
Because each Job can have multiple invoices then I need each invoice to be linked to it’s parent Job. Admittedly, I only envision 3 or 4 invoices per Job so I didn’t feel a ‘List’ was necessary.
3 things is a list, so you can’t have a Invoice field on the Job and expect anything to work if you’re trying to associate multiple invoices to the Job (you’ll just be overwriting the previous one). It has to be a list here (assuming you want to link the data that way).
This successfully saved the Invoice to the database but, as with this one, the Invoice refers to the Job but not the other way around so I can not refer to ‘Job’s Invoice’.
Then do it the other way round (you have no choice about that if you want to refer directly to the Job’s invoice - although as I mentioned above, assuming a Job can have more than 1 invoice, this will have to be a list AND you’ll need a way to specify which invoice from the list you’re referring to).
But overall, I think you’re massively overcomplicating this… it should be fairly simple…
You database should be:
Job
List of Invoices
Invoice
Job
Your Create/Edit invoice group should have a content-type of Invoice
Use conditionals, based on whether that group’s invoice is empty or not, to determine whether you’re creating a new Invoice, or editing an existing one.
When you create a new invoice, set the Job field to the relevant Job (refer to wherever else on your page that job is defined), and then add the Invoice to the Job’s list of invoices.
To edit an invoice just display the current cell’s invoice in the Edit Invoice group.
1 Like
Thanks Adam, it’s strange because my website never had the invoices as a list and I was able to create/edit as many invoices as I wanted within a Job. In fact I didn’t understand the point of a List because of this. However, I appreciate you clarifying how the database should be set up and I will take your advice and see how I get on!
My database is now set up as you suggested. The ‘create invoice’ button is on a floating group (for mobile users) so I am unable to refer directly to the Parent group. I have tried the following but it’s not saving the invoice to the Job.
I previously sent data from the header floating group ‘create new invoice’ button but that is now not possible because of the data source change. The data I am trying to send is the data from the previous page 'Job-invoices.
As you can see, any fixes result is a complete breakdown is the system because I don’t have enough knowledge in this area. This is why I was certain I needed a freelancer to set up the database and the initial pages, from there I would be able to built on top of it. Unfortunately, as I said before, I couldn’t find a freelancer who could do it without someone major no working. I deleted my entire old website to start from scratch and try and learn every step but here I go again, stuck!
@adamhholmes is a very patient and generous guy! kudos. @darren.james7518 I think the problem you are struggling with is Database Design. The Bubble tutorials make you think building an app is as easy as throw Elements onto a page, make them pretty, point them to the database and you are done. It’s not that easy.
In my opinion with Bubble, the database comes first. Subsequently trying to retro-fit privacy rules, and fight against the database design after the app is built is a very hard way to do it.
If you want to find some design help, consider this https://nocodeguides.io/
1 Like
Yes @adamhholmes is always super calm and has helped so many people, top guy.
You are right about the database, I have always started with the database but each time I build the site I realise it was wrong. It’s not the actual database that’s the issue most of the time, it’s the difficulty in sending data from one data source to a different data source.
Thanks, I did check you guys out before and will take another look now.