Category Archives: Visual Studio Code

Import CSV files into Business Central

Microsoft Dynamics 365 Business Central can import CSV files. It’s done with the wrongly named XMLPort (at least for this purpose) objects. The challenge is to get the indentions right, so here is a barebone XMLPort object that will read a CSV file.¬†

Image result for csv files

The important parts are the setting Format that uses the VariableText type and getting the initial indentation right.
Copy this into Visual Studio Code, and you’re up and running with CSV files and Business Central in no time.

xmlport 50100 "Import Demo CSV"
Caption = 'Import Demo CSV';
Direction = Import;
TextEncoding = UTF8;
Format = VariableText;
FieldDelimiter = '"';
FieldSeparator = ';';

tableelement(GenLine; "Gen. Journal Line")
AutoReplace = false;
AutoSave = false;
AutoUpdate = false;
XmlName = 'GenLine';
fieldelement(f1; GenLine."Debit Amount") { }
trigger OnBeforeInsertRecord()
// Brilliant code right here
AwesomeVariables : Code[20];

Another extension for VS Code to your Toolkit

The SQL Server extension for Visual Studio Code is a nice way of avoiding SQL Server Management Studio for when you need to do some light SQL’ing while working in VS Code

You can do queries directly from VS Code even with awesome intellisense and nice formatting.

VS Code is getting closer and closer to becoming a one-stop destination for all the things we need to with NAV and Business Central.