Hierarchy: Creating new child from parent via a microflow button
I have a hierarchy (deliverables). I have a dataview on deliverable with an embedded datagrid on the child deliverables. I want to be able to create a new child and copy some initial values (the project) from the parent deliverable. The modeler does not allow that because I cannot pass the enclosing data view entity because it is related to the data grid entity. I also cannot use an aftercreate in which I retrieve the parent because the context is set after the aftercreate. And I don't want to do it in a beforecommit because the project constrains other fields (projectmembers). How can I do this?
Frans Verschoor (FraternIT)
I can think of a few ways to make this work, but all of them feel like a workaround:
change your domain model, so the entities in your form are no longer of the same type (by adding some dummy entity for example); you probably don't want to do this just to make one form work
add a Java action that stores the parent entity when you open the data view, and retrieve it again when the 'new' button is pressed; this option is a bit too much work I think (you need to store the entity per user session to make it function properly)
place the 'new' button (which already is a microflow trigger in your case) not on the data grid but on the data view; the easiest solution, but if you want the button to appear with the other buttons on the control bar of the data grid you need some custom styling