How can I create an object without committing, then create a child object and commit that one?

Quick question: - I create an object without committing. - Then I create a child object, and commit that one. - As I understand, the parent object will be autocomitted. Is this a good way to model my flows? Or should I always manually first commit the parent object? - @ Bert
1 answers

On many other platforms, the situation you describe would result in an exception: your child record is committed to the database but the parent it refers to does not exist. Do not rely on this to work in Mendix. It is generally speaking a modelling error. The runtime attempts to fix it for you but this is really error prone.

A common example is creating a parent object, without commit and taking pictures that are linked to it. A recipe for disaster. Always commit the parent first.

In this situation I often split the process: A MyObj_New page with some basics, the save button calls a microflow that commits the object, closes the page and then opens the edit page. Or just commit your object when a child object is committed. Be prepared for objects in your database that do not meet your validation requirements. - @Marcel Groeneweg