How and where to create associations after XML-import
Hoi, i'm new to Mendix, but i will try to clearify as much as possible. Today I was finally able to import my xml-files. However these files have no knowledge how the different sections are related to each other. But in my domainmodel I have these relations. This means when I import my xml-file, I still have to create records for the associated tables. I can guess I have to use a workflow for this. But where and when do I call this workflow. And can someone give me an example of such a workflow or description how what is needed in this workflow. My guess would be to iterate through all orders and set the related table fields. To keep it simple let's say how to connect customer and order. both table have a field through which I can relate the two table. But this relations is not in the XML, so I have to relate the tables after import. any help is appreciated.
You can use the "find by microflow" option. This enables you to use a microflow to create the object (or search for it). In this microflow, you can also do stuff like set relations such as the ones you're talking about.
Hi Achiel, thanks for the answer. I guess you mean that in my domainmodel I can set actions for the entity. That is what I found. I thought an AfterCommit eventhandler would be the place to add a microflow. But when I tested this, it didn't work.
I finally could figure out (using breakpoint) that this event isn't fired when I use my xmlimport. It only fires when I add a new entity through a form.
The only place I need to set the association is when I import files in my application. It seems that eventhandlers of my entities are not the right place for this.
Any other suggestions?
Oke, I finally found it. After import I use a workflow to connect the association. I forgot the enable the commit.