XML import question: seperate actions based on found or update

0
Because our client does not have a ERP with a webservice available we have to make use of XML im- and exports. I would like to make an import that does 2 things: Find the object, if it has not been found -> create it with the following attributes: Start Date End Date Quantity If the object has been found: update the quantity but leave the Start and En date as they are. The reason for this is that the start and end dates are updated in the clients ERP, but we would like to save the original dates in order to do some comparisons lateron in the process. I was thinking to just use a convert microflow that says: If StartDate is empty then [StartDate from XML] else StartDate however I can't seem to access my mendix object in this microflow during the XML import, any ideas on how to solve this issue?
asked
3 answers
0

Create a seperate domain model for importing, after importing pass the imported object or list of imported objects to a microflow which synchronizes your data.

answered
0

I think the best thing to do is to import into a non persistable (temporary) object. Let the Import XML action in your MF return the NP object. Then you can retrieve the actual object from your DB or create a new object and do all kind of changes you like.

answered
0

You can use a 1-* association between 2 NP objects. One will be the highest node in your XML. This is the object you want to recieve back. Then retrieve over the association and you get a list of all objects that are imported. Then loop over this list and do the changes.

When you have the following xml:

<Records>
    <Record>
        <id>value</id>
        <startdate>value</startdate>
        <enddate>value</enddate>
    </Record>
    <Record>
        <id>value</id>
        <startdate>value</startdate>
        <enddate>value</enddate>
    </Record>
    <Record>
        <id>value</id>
        <startdate>value</startdate>
        <enddate>value</enddate>
    </Record>
</Records>

Create 2 NP objects: Record and Records and associate them with a 1-* association. Then be sure to map these in your XML-Domain mapping. Now when you import the XML you get the Records object. With a simple retrieve over association you get all Record objects.

answered