Object in microflow updating before commit

0
On the home page of my app I have a data view that loads an object editable by a popup window. I’m having an issue, though, where whenever I edit one of the fields in the popup window and then click away from the field, the change is immediately reflected on the home page. Since it’s just a popup window, I can see the field changing in the background. The expectation is that the object is only updated when the form is saved.  Even though the object is updated on the home page in the background, the cancel button does work. It reverts the object on the home page to whatever was there prior to editing the field in the popup. I’ve spent much longer than I would like to admit trying to figure out what is causing this behavior. I’m very new to Mendix, so I’m still getting the hang of how objects are handled. The only thing I can think of is that somehow the fields are editing the object itself instead of even before a commit is executed by the save. What’s the correct approach to handle a scenario like this?   Thanks! Chris
asked
2 answers
0

Hello Chris,

This is probably because the object (in your homepage) is not coming directly from the database, which means that it is living in the browser's memory and whether you modify it in the same page or in a pop-up, the object instance in your homepage is the same instance in your pop-up. Depending on your design and requirements there are multiple ways to approach this (using a temporary non-persistable object that has the attributes that you’re trying to edit in your pop-up page and then copying its details to the object on the homepage on save or changing the source of your homepage’s data view to start getting the data directly from the database).

If that doesn’t answer your question, please edit your question to include a screenshot of your homepage and tell us more about your domain model (if you think it’s relevant) and your requirements.

answered
0

Hi Chris,

 

If you only want the object to change (in the background) when a user saves their changes, you can do this by creating a non-persistent version of the object, which will be used for the editing part, and commit these changes to the persistent version object when a user saves them.

 

To do this you need to  create a ‘copy’ of the object you want to edit in the domain model, but make this a non-persistent object. Create this object in a microflow when a user want to edit, and show the popup page. Edit this non-persistent object in the popup, and when a users clicks the save button, transfer these values to the persistent object in a microflow. 

 

Hope this helps,

Dave

answered