Handling empty and useless objects

In Mendix there are 2 issues sometimes occur: empty objects are saved in DB (like when I create new object in a micro-flow and without committing it ,It will be saved as an empty object) -->so I handle this issue by creating scheduler micro-flow to clear the empty objects useless objects(like when I am adding a data-grid object to a new data-view object without saving data-view object leading to saving the data-grid object without relation to data-view object which means that it is useless) --> so I want to delete them but I am worried if I create scheduler to delete all the data-grid objects in case of it is not associated with the data-view object , It would leads to deleting current data-grid objects of any of current users which are going to save the data-view so any recommendation or advice to deal with those 2 issues. Thanks in advance.
2 answers

Another solution is to add an attribute, for example, isNotEmpty, which defaults to false. On your datagrid you can add the constraint [isNotEmpty]. You can set the attribute to true in your save microflow or in the after commit. This way the empty ones will not show up anywhere. (And they can easily and reliable be found in an scheduled event)


A microgolf on rollback of the dataview could delete orphans immediately.

Since the datagridobjects in creating a dataview refer to the empty dataview deleting orphans should not be an issue.