WMFlatFile converttostring

I have been trawling through the forum and training but haven’t found an answer so far…
I’m starting from a document with two types of records within and want to convert that to a csv format with two types of records.
For argument’s sake, let’s say it’s a sales order (with some fields like salesordernumber, total price, shipping details,…) and within the sales order multiple sales line items (fields: sku number, unit price, quantity…).

The required output is:
OR1, salesordernumber, total price, address line, postcode
OR2, salesordernumber, sku number1, unit price1, quantity1
OR2, salesordernumber, sku number2, unit price2, quantity2

A flatfile schema seems to indicate that you can have multiple record type definitions, which is what I like to think I need here.
I gave it a go and it failed. I don’t know the inner workings of the wmflatfile:converttostring but I think it might not like the fact it has to loop over the line items.

Do I need to do this in multiple steps to obtain the desired output? Any advice is welcome…

No you don’t, you can do it with a single call to convertToString. However, you need to make sure that in your ff schema that you have a record identifier that matches the repeating record elements in your document e.g.

Make sure that the properties are set appropriately i.e. Ordered = false and Max Repeat = Unlimited.
Also the reference in the document type must match the flat file record id i.e. OR1. Use the property “alternative name” If you want the record identifier in the file to be different to that in your document type.

I have attached an example wm package for reference.

JcScratch.zip (13.9 KB)


Thanks for that. I’ve just re-read my post and there’s one thing that I fear I haven’t conveyed. I’ve attached my example doc (created from a Json file I received).
The main difference is that there’s a list of documents under the main document, and those will be OR2.

MreyDoc.zip (3.6 KB)

I think I understand your problem now.
You will need to first map the document that you received i.e. the one that you provided in your package to a document as defined by the flat file schema i.e. when you create your schema as I did, you will then have to click on the 'create document type" button shown in the toolbar

You will then use a map prior to calling the convertToString to map your json deliveryRequest document to the ff document and then use that as the input to the convertToString service.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.