How to handle auto commited objects

0
Hi folks, I have some situations in one of my apps where objects are auto committed, mainly because I have an initiated object and the user adds new objects in a datagrid over Xpath or database. Example, create a new invoice and add invoice lines. I do not want to use over association because then an invoice line is deleted when you press the cancel button. Why are auto committed objects visibile to other users? This seems to be pretty dangerous. Wouldn't it be better to hide auto committed objects from other users until they are committed. I sometimes get errors that auto committed objects existed when the user logged out. All objects are rollbacked where possible but it is not possible to rollback your object when you press a menu item, browser back button or the sign-out button. How do you guys solve this?
asked
1 answers
0

In general you should strive to avoid auto-commits. I think you need to make a decision whether you're committing data or not as users are entering it. My initial recommendation would be to keep everything in memory until you're ready to save.

You state:

I do not want to use over association because then an invoice line is deleted when you press the cancel button.

If you're trying to avoid deleting the InvoiceLines when the Invoice cancel button is clicked, you have a few options:

  • Option A: Turn the cancel button into an action button: in a microflow:

    • Retrieve InvoiceLines over association and aggregate to get a count of them
    • If the count is >0, prompt the user with a confirmation page (e.g., are you sure?)
    • Otherwise delete the Invoice and close the page.
  • Option B: Turn the InvoiceLine save button into an action button

    • In a microflow, commit both the InvoiceLine and the Invoice
    • This does have the effect of making the Invoice visible to other users
answered