[CSVUtil] Matching header when exporting CSV

Forge Component
Published on 2019-09-28 by Wei Zhu
27 votes
Published on 2019-09-28 by Wei Zhu

Hi Everyone,

I am currently trying to use the ExportRecordList2CSV function and I am seeing that when the CSV is exported it is rearranging the attributes alphabetically and also by text/integer (At least that's what I think it is, it could be the ToObject() function as well). For this export I need the attributes to be in a particular order so I was wondering how to arrange them so they stay on the CSV. I have tried to use the custom header but that only replaces the header and doesn't rearrange the attributes. Any help is appreciated!


Hi Bryan

If you need export attributes with particular order, You need

- Create a new structure and define a new List variable

- Assign original List to new List and mapping the attributes

And I'd like to point out

- Rearranging the attributes alphabetically

  CSVUtil DID NOT rearrange attributes in structure / entity.

  It DO REARRANGE the order of attributes of  Record Data Type by name.

  This is because sometimes attribute in Record Data Type are different between Extension and Service Studio.

- CustomHeader

  CustomHeader is only used for first line of CSV, it will not affect order.