Object commits when it shouldnt

1
Hello everyone,   I have a problem with the creation of objects. To give some background I have an application here, where the main goal is to create lineservices. There is 2 types of lineservices, direct ones and order consoles. An order console is a linesercice where you can add aditional shipments to it. We made an overview page to do this, which commits the entitiy called shipment. Only problem is that it commits it too often, so it commits when it shouldnt and then we have a whole list of empty shipments.       At this page I got a previous button to go back to my previous page. Basically whenever I close this page it commits a new shipment no matter how I close the page.     As you can see there is an empty 'shipment’ added.       This is the template we fill in to add a shipment.     This is the microflow on the data view and here it creates the shipment.
asked
2 answers
1

are you sure the object shipment is commit? what happen if you reload the page? 

sometime the object is not store on the database, but it is display on your screen because it is still in "state”, if it's the case try to implement a rollback or a new process when your are going back to your page.

if your object is commited, try to see if you don't commit that object somewhere, and check if there is no auto commit that is happening : https://forum.mendix.com/link/space/other/questions/92454

answered
1

I think Yehoshua is correct. You are always creating a new Shipment when you visit the page as that is what the datasource microflow is doing. I suspect in this create action you are also setting the association between LineService and Shipment. I also suspect on the page that calls your datasource microflow you are retrieving by association all Shipments for the LineService. This means when you go back, the Shipment is still in memory so is showing up over the association. If you were retrieving by XPath it wouldn’t show as that always go via the database.

I think you should refactor how the association is set. It would make more sense to set it when you save the Shipping object. This means it would only show up on the association when the user has specifically chosen to save it. If you clicked the back button without saving, the object would then not show over the association.

I hope this makes sense and helps. Good luck!

answered