Hi all, I am working on the following process: Microflow 1 Create Variable "NewPurchaseOrder" Show Page "PurchaseOrder_NewEdit" User can create a new purchase order Microflow 2 Save Button on "PurchaseOrder_NewEdit" is replaced with microflow-button to check, if user has updated certain fields with exclusive split and expression statement: a) If fields are updated, then commit object to database; b) If fields are not updated, then rollback object Why is the rollback needed? Purchase order entity has an autonumber field to create a unique purchase order ID. This ID has to be a sequential number without missing pieces. Purchase ID 1 Purchase ID 2 Purchase ID 3 Purchase ID 4 None of the number should be missed out. The rollback does not work. Any suggestions?
I believe you have a few options to achieve this functionality, as the standard Mendix Autonumber will set aside a new value for each object created:
Option 1: Create and manage your own ID number
For this option, you could specify your own attribute and use commit microflows to manage the ID numbers. You leave yourself open to potential issues with concurrency, if two users try to create commit/save a purchase ID at the same time.
Option 2: Use a non-persistable entity to handle everything before you save and commit
Create a non-persistable entity that mirrors your existing PurchaseOrder entity. Create that object and pass it into the PurchaseOrder_NewEdit page. Let the use make changes there, then create and commit the real PurchaseOrder entity when the user clicks save.