Forum Discussion
If the Header Fields property in the snap is not set, the headers will be pulled from the incoming document. Also, the Snaps try to preserve the order of the fields in the document. So, it’s possible things will “just work” right now for you.
If you do need to change the order of the fields in the document, you should be able to do it in the mapper using the expression language. You’ll need to get the list of fields, sort it by the key, and then reconstruct the object.
You can get the list of fields in the document using the entries()
method and then sort()
that list. The sorted list of key/value pairs can then be fed into the extend()
method to produce a new object. The following expression does that and does a reverse alphabetical sort:
{}.extend($.entries().sort((left, right) => -left[0].localeCompare(right[0])))
I’m attaching a pipeline that demonstrates both scenarios, using the natural order of the fields in the doc and doing the above sort:
CSVColumnOrder_2018_05_10.slp (11.8 KB)