Hi Jagan,
You can use the events - Mendix Marketplace - Events, use it in the edit page and configure it to save changes every x seconds.
But with the above approach, data is saved every x seconds even if there is no changes. To optimize it even more, you can call a nanoflow instead of save changes and in nanoflow check if the object is modified using javascript. If modified then commit else don't commit.
Reference to JS - Mendix 11 Dojo Client Documentation mendix/lib/MxObject
Hope my answer helps. Reach me out for any queries.
In addition to a save button, you can put several events on input fields. You can trigger microflows on change, on enter, on leave, etc. You'll have to think about when you want to save the data - do you even want to save when they're in the middle of a word? Or only when they leave the field?
In the microflow you put in the event, simply trigger any validation you need and then commit the value. Do note that this will lead to more database transactions, so if you have an app with high numbers of users this might have an impact on performance.
Hi Jagan,
For this requirement, you don't need to create a separate save mechanism. You can use the On Change event of the input widgets to commit the current object.
Since your object is already created when the user opens the form, the flow can be:
Create Record
↓
Open New/Edit page
↓
User enters/changes a value
↓
On Change
↓
Commit the current object
For example, on an input field:
Input widget → Events → On change → Call a microflow
The microflow can simply receive the current object and commit it:
ACT_AutoSave_MyObject
|
v
Commit $MyObject
Set the Commit option to Yes with event handlers.
Mendix's Change Object and Commit Object(s) activities explicitly support committing the changed object to the database.
However, there is an important limitation with this approach: On Change is not fired for every individual keystroke. Mendix triggers On Change when the value changes and the user leaves the input (for example, by tabbing to another widget).
So if the requirement is:
“Save every single character immediately while the user is typing”
then a standard Mendix On Change event is not the right mechanism.
If the actual requirement is:
“Don't lose the latest value if the user moves between fields or something goes wrong”
then On Change + Commit is a good Mendix-native solution.
I would also avoid putting a commit microflow on every field if the page contains many inputs. It can generate a large number of database updates and unnecessary server requests. Instead, you can use On Change only for the fields where early persistence is actually required.
One more thing: if the user loses the connection while typing a value that has not yet triggered On Change, that value is still only in the client and has not been committed to the database. A normal web application cannot guarantee persistence of every keystroke this way.
If losing unsaved data during a connection failure is a hard requirement, I would consider an offline-first/native approach or a client-side draft/autosave mechanism rather than committing every keystroke to the server. Nanoflows run on the client, whereas microflows run on the Mendix Runtime.
So for a normal online Mendix application, my recommendation would be:
Create object
↓
Open edit page
↓
On Change on required fields
↓
Auto-save microflow
↓
Commit object
and keep the normal Save button as the final explicit save/validation action if the business process requires it.
Hope this helps.