I have created XMLPort to export data to CSV file in business central online.
My XMLPort contains both field elements and text elements.
How can I set column headers for my CSV file?
I have created XMLPort to export data to CSV file in business central online.
My XMLPort contains both field elements and text elements.
How can I set column headers for my CSV file?
Export them in a separate table element.
In C/AL visual designer it would be something like this:
And the same in AL
xmlport 50100 "Export G/L Entries W/Headers"
{
Format = VariableText;
TableSeparator = '<NewLine>';
schema
{
textelement(root)
{
tableelement(Headers; "Integer")
{
SourceTableView = WHERE(Number = CONST(1));
textelement(EntryNoHeader) {}
textelement(GLAccNoHeader) {}
textelement(AmountHeader) {}
}
tableelement(GLEntry; "G/L Entry")
{
fieldelement(EntryNo; GLEntry."Entry No.") {}
fieldelement(GLAccNo; GLEntry."G/L Account No.") {}
fieldelement(Amount; GLEntry.Amount) {}
}
}
}
trigger OnInitXmlPort();
begin
EntryNoHeader := GLEntry.FieldCaption("Entry No.");
GLAccNoHeader := GLEntry.FieldCaption("G/L Account No.");
AmountHeader := GLEntry.FieldCaption(Amount);
end;
}
Thanks Alex. I have already accomplished this using integer table but there was a blank row just after the header row. Setting TableSeparator = ‘’ fixed the issue.