Partial rollback? - Mendix Forum

Partial rollback?

0

How can you do a partial rollback?

For example, imagine a trading company. As customer you can make an order. The order has multiple orderlines. This means you have two entities, order and orderline, with a one-to-many relationship in between. I do not want to commit orderlines seperately, but I want to commit them together with the committing of the order. Therefore, when I add an orderline, it is not committed yet and remains in memory. Later, the user wants to edit the orderline. He comes on the page. There he presses cancel, and that is when I would like to be able to do a partial rollback. If I do a full rollback, then the orderline is also removed from the order.

Is there a way to only do a rollback of the changes made in the edit, but not of the whole object in memory?

asked
2 answers
0

It cannot be done since you have no version of the orderline to rollback to. The user has just changed the only available version of the recently-created-not-yet-committed orderline. Vianey is right, only with custom behaviour under the cancel button you can do this, but still, you will need to have the original version stored somewhere. Perhaps save the current orderline upon opening the page, or OnChange of any orderline field in that page.

But it becomes a snakepit very soon and if you have any say in it, I would save each orderline separately after each change and save yourself this complexity.

answered
0

Theo, the quickest solution may be custom behaviour underneath the cancel button and delete the page parameter orderline (and association).

answered