On Change Event conflicts with Cancel button

I have an input field on a page with an OnChange event microflow.  If I change the value in the field and then move the focus the microflow runs and updates some other fields.  If I then click the cancel button all the changes are successfully rolled back.  BUT if I change the value and then directly click the cancel button, without first losing focus from the field, the changes don't successfully roll back.  The rollback seems to complete before the OnChange microflow and the final state of the object contains some or all of the changes (which I can see on the page I return to).  This seems to be a case of last one wins but should there be some mechanism to ensure that the Cancel action always wins? Also is there a workaround I can employ?
2 answers

I've enountered this situation with an On Change not being committed to the database due to the fact that the Save button completed before the On Change. Not sure whether this effect has always been there or is in fact a bug.

In my situation the workaround was fairly simple: I opted to create a custom Save button where I ensured the On change actions were also triggered before committing the object.

Looking at the problem from your situation, it might be worth it to submit a ticket with Mendix Support anyway. Reason being that my solution (custom microflow) wouldn't have the same result for you. It could still be the case that your custom cancel button finishes before the On Change.

Do note that while the rollback doesn't appear to have happened, this is merely because the On change fired after your rollback. So as long as the On change doesn't commit your object, this 'change' should only persist within your session.


Are you performing a Commit in your On Change Microflow? If so, is this actually needed?