Using CSV Ports

Using CSV ports in Microsoft Business Central is advantageous due to their simplicity, universal compatibility, and ability to handle large data volumes efficiently. They allow flexible data mapping and transformation, reducing the need for developer support and enabling quicker setup for regular data tasks. CSV ports also facilitate compliance and auditing by providing an easy way to export records. Finally, CSV files are ideal for integration with other systems, enhancing Business Central's interoperability across different platforms.

To create a CSV port for data import or export

To set up a CSV port, follow these steps:

  1. Choose the Search icon, search for CSV Ports, and choose the related link.
  2. On the action bar, select New.
  3. In the General FastTab, enter a code and a description for your new CSV port. The Code field is mandatory.
  4. In Direction, choose whether this is a port for data import or export.
  5. In the following fields, you can enter or change a value to define how the data is structured. Not all fields need to have a value.
FieldDescription
TableSelect the table in Business Central that the CSV port will interact with. This determines where data is imported to or exported from.
Table CaptionEnter a descriptive caption for the selected table to help identify the data purpose and context within the port.
Text Format external FileChoose the text format for the external file. The options are: MSDos, Windows, UTF8, and UTF16
Fixed Column PositionSpecify if columns in the CSV file have fixed positions. This setting allows the CSV port to treat each column consistently based on its exact position rather than by name or type.
Length of LineDefine the maximum character length per line. This helps manage large data rows and avoid errors in CSV files with varying line lengths.
SeparatorEnter the separator type used in your CSV (Comma-Separated Values) files. The role of a separator is to demarcate two distinct entities so that they can be distinguished. These characters separate fields of data within each line.
DelimiterDelimiters are used when files contain both commas as separators and descriptions with embedded commas.

From here on, the fields you need to fill in depend on whether you're creating a CSV port for import or export.

To create a CSV port for import

If you chose Import in Direction in the General FastTab, the CSV Port Card will display the Import FastTab.

Fill in the following fields where needed:

FieldDescription
Date FormatEnter the date format used in your CSV file. This setting is used during file import to ensure the correct formatting of the posting date. The date format is based on the .NET DateTime format. For example, ddMMyyyy.
Decimal SeparatorSpecify the character used as a decimal point. For example, period or comma.
With direct Gen. Journal ImportEnables direct import into the General Journal.
Check if Gen. Jnl. Batch is emptyVerifies that the General Journal Batch is empty before import to prevent accidental overwrites of existing data.
Open Gen. Journal BatchAutomatically opens the General Journal Batch after import, allowing immediate review and editing of the imported data.
Skip Header LinesEnter the number of header lines to skip in the CSV file, typically to avoid importing column headers or metadata rows.
Skip Footer LinesEnter the number of footer lines to skip in the CSV file, useful if there are additional notes or metadata at the end of the file.
Run OnModify / OnInsert triggersEnables data triggers that run actions when records are modified or inserted during import, such as validating or recalculating values.
Execute OnValidate triggersTriggers field-level validation logic during import, ensuring imported data adheres to Business Central’s data integrity rules.
AmountsSpecifies a setting for amounts: As saved, Absolute, or Change Sign.
Filter stringEnter criteria to filter rows during import, allowing only data that matches the specified criteria to be imported.
Use Filter to excludeSpecify if data is to be excluded during import based on a filter, preventing rows that match certain values from being included in the data import.

To create a CSV port for export

If you chose Export in Direction in the General FastTab, the CSV Port Card will display the Export FastTab.

Fill in the following fields where needed:

FieldDescription
Date FormatEnter the date format used in your CSV file. This setting is used during file import to ensure the correct formatting of the posting date. The date format is based on the .NET DateTime format. For example, ddMMyyyy.
Decimals FormatDefine the format for decimal numbers in your CSV file, specifying how many decimal places to include. This setting helps maintain consistency in number precision across data exports.
Decimal SeparatorSpecify the character used as a decimal point. For example, period or comma.
Thousands SeparatorSpecify the character to use as a thousands separator in exported numbers.
Format of boolean fieldsChoose the format for exporting boolean fields, "True/False," "Yes/No," or "1/0".
Format Option ValuesSet how option values should be formatted in the export, either as values or as text.
Export Field NamesSelect whether to include field names as headers in the exported file. This is useful when the CSV file requires column headers for easy identification or compatibility with other systems.

To import data using a CSV port

To use a CSV port to import data to Business Central, carry out the following steps:

  1. Choose the Search icon, search for CSV Ports, and choose the related link.
  2. Select the CSV port you want to use.
  3. In the action bar, select CSV Port > Import/Export.
  4. Select Click here to browse to select the file you want to import.

To export data using a CSV port

To use a CSV port to export data from Business Central, carry out the following steps:

  1. Choose the Search icon, search for CSV Ports, and choose the related link.
  2. Select the CSV port you want to use.
  3. In the action bar, select CSV Port > Import/Export.
  4. Select Yes to download the created file.