Save repeating group data just when clicking on the save button

Hello,

I´ve a page where users can create invoices and in the invoice page they can add invoice lines (thing that is connected to the invoice). So invoice lines is a repeating group where you can add multiple lines.

But I just want to save the repeating group´s data on the invoice_line database till the user clicks on the “SAVE INVOICE” button that is in the bottom of the page.

So when clicking on the “SAVE INVOICE” button two things must happen: first, modify the invoice data which is an actual thing and second add the invoice lines data to the invoice_lines thing that is connected to the invoice.

Here is the app:

I´ve been playing a bit with custom states but I haven´t been able to find in the dropdown of “set field…” the custom state.

@NigelG you´re good at this, could you take a look?

Thanks a lot.

Hi,

I´ve been playing a bit more with custom states but I´m not able to save the data of the repeating group lines in the database.

Can anyone take a look at this, please?

Thanks.

Hey @ryanck,

Custom states don’t save to your database. They’re just temporary states on the element level, not data. You’re on the right track - I looked at your database structure and have a question that might help:

Why not create the invoice when the user navigates to this page? Then, anything done on that page modifies data to an existing invoice. Right now, your invoice lines need an invoice to reference but you’re not creating the invoice until the save button is clicked, so I think you need to reverse some of the workflows.

So how I’d approach it is when the user navigates to this invoice page, a new blank invoice is created. When a new line is added, it can now reference the current invoice and be added to the invoice’s “list of lines.” This is a great place to make use of the new auto-binding feature so that whenever a line field is changed, it automatically gets updated in the DB. The save button would then serve as a confirmation and you can show a message or navigate away.

Also, you can offer a “discard” button that deletes the invoice and related invoice lines and then navigate away so that you don’t end up with a bunch of drafts that never get completed. Does this help?

2 Likes

Thanks for your reply @romanmg,

Great explanation. I did not know that custom states don´t save in the database. This is like really helpful since now I know with which elements I can play with.

As you´re saying when the user goes to that page a new invoice gets created. I´ve set up this in the “facturas” page, so when a user clicks on “new invoice” button a new invoice gets created.

Then lines are saved on the database right away.

As the custom states is not possible I´m going to play with an status field that I´ve on the page (I already did).

There are some things to consider, and mostly it´s when editing the invoice because I need to keep track of modifications.

We´ll update as soon as I get something.

Thanks.

Awesome! Happy to help.

And like I mentioned too, definitely check out the new auto-binding feature as it could save a lot of effort for updating fields.

1 Like

I´ve tried to auto binding feature but I don´t want the users to see the progress bar whenever they change a field.

Thanks a lot.