Mapping flat incoming documents to object output
Hi,
I have a csv file containing rows with customer orders which I want to map to an XML invoice object which generates an invoice containing all the customer orders.
The incoming data looks like this:
CustomerId | Price | Quantity |
4 | 20 | 1 |
4 | 20 | 2 |
5 | 30 | 1 |
5 | 30 | 2 |
The target schema is an XML with the following structure:
My desired outcome would be to loop through the incoming rows where customer id is e.g. 4, and write the two orders as InvoiceRow elements, within the “invoices” object, producing two documents as output looking like this:
My current pipeline looks like this and just maps the four flat incoming documents to four output documetns:
Does anyone have any tips on how to acchieve this?
Welcome to the community Daniel!
Try a GroupByFields on CustomerId to create a document for each (InvoiceOrder), and then another generic GroupByN=0 to clump everything together into one document (Invoices) before converting to XML. Can also probably just convert as-is to XML, then use an XSLT to re-arrange/format as desired.