Create thing in memory - invoice lines

I am working on page which allows users to create new invoice with few fields + line items.

I have Invoice and Invoice Items in database. The requirement is to support dynamic numbers of invoice items within an invoice.

I am using repeating group for line items, but I stuck with the logic. I am able to create new Invoice Item through the workflow and add to the custom states which is used as data source for repeating group. But it creates new Invoice Item in database. If user decides to close the browser, all these dummy Invoice items will remain in database.

I am looking for solution to create thing (Invoice Item) in memory and add into the custom state, which is list of invoice items.

Is it possible?

If I’m understanding right just populate the page based off of slug or URL. Then on page load set the state with the search for invoices line items.

I will try to explain in more details.

  • I have repeating group which has custom state invoice items, which is list of invoice items.
  • Repeating group has invoice item as type of content and data source is custom state invoice items
  • the idea is to add new empty invoice item into the custom state in order to show in repeating group

This is possible with creating new thing (invoice item) and add to custom state, but it creates new empty invoice item in database, which i try to avoid.

So I need mechanism to create invoice item “in memory” and add into the custom state.

I ran into this last year with my app - I wanted a way for a user to create an ingredient to add to a custom state featuring a list of ingredients for a recipe. I couldn’t find a way to create something that only existed in custom state without it touching the database - so ultimately I so moved to creating the thing in the DB, and adding that thing to the repeating group. It may be the heavier way to go so I’m hoping someone else found a better solution!

1 Like