DocumentationDataMigrate ProMapping

DataMigrate ProMapping

NAV 2009 and Earlier: Importing Source Metadata from Excel

For NAV 2009 and earlier, import the source metadata into DataMigrate Pro with an Excel template, because the object definitions exist there only as BLOBs.

1. Background

For NAV 2013 and later, DataMigrate Pro reads the table and field metadata of the source directly from the SQL database (Object Metadata, NAV App Object Metadata, $ndo$navappschemasnapshot). NAV 2009 and earlier versions (database version < 7.0) do not provide this information in a readable form. The object definitions exist only as binary BLOBs in the Object table.

Instead of developing objects in NAV for this purpose, the metadata is exported through two virtual tables of the NAV Classic Client, pasted into an Excel template generated by DataMigrate Pro, and then imported. The import populates BC Migration Tables and BC Migration Mapping in the mapping database and thus replaces the metadata step of the auto-mapping. After that, --buildlocalmapping and --buildmapping run as usual.

2. The virtual tables

2000000001 "Object"

Returns the list of all objects, including the tables. Columns (in the order of the NAV form):

Type Company Name ID Name Modified Compiled BLOB Reference BLOB Size DBM Table No. Date Time Version List Caption Locked Locked By
TableData 78 Printer Selection No Yes 0 0 05.11.2008 12:00:00 NAVW16.00 Printer Selection No
TableData CRONUS AG 3 Payment Terms No Yes 0 0 05.11.2008 12:00:00 NAVW16.00 Payment Terms No

Only rows with Type = TableData are relevant for the import:

  • Company Name empty ⇒ the table is not company-specific (Data per Company = 0); there is exactly one row.
  • Company Name filled ⇒ the table is company-specific (Data per Company = 1). One row appears per company; the import combines them by ID.

2000000043 "Field"

Returns all fields of all tables. Columns:

TableNo No. TableName FieldName Type Len Class Enabled Type Name Field Caption RelationTableNo RelationFieldNo SQLDataType
3 1 Payment Terms Code Code 10 Normal Yes Code10 Code 0 0 Varchar

TableNo, No., FieldName, Type, Len, Class, Enabled, and Type Name are used. RelationTableNo/RelationFieldNo and SQLDataType are read but not stored.

3. Procedure

All steps are available both as a CLI command and in the MappingEditor under Mapping functions (area BC Migration Tables): Create source metadata template (NAV 2009)… and Import source metadata from Excel (NAV 2009)…. The GUI import asks whether to only check (dry run) or to write, then shows the summary and can open the validation report.

Step 1 – Create the template

CLI
DataMigratePro.exe -t createsourcemetadatatemplate [-o <Pfad>\SourceMetadataTemplate.xlsx]

Without -o, C:\Migration\DataMigratePro\export\SourceMetadataTemplate.xlsx is written. The workbook contains three sheets:

Sheet Content
ReadMe Short instructions and import rules
Object Header row exactly like virtual table 2000000001
Field Header row exactly like virtual table 2000000043

Step 2 – Create the forms in NAV Classic and export them

  1. Object Designer → Form → New. Enter 2000000001 as the Table, use the Form Wizard to create a tabular form, and include all fields in the default order.
  2. Run the form (Run), select all rows (Ctrl+A), copy (Ctrl+C), and paste into the Object sheet starting at cell A1. You may overwrite the header row of the template in the process. The import recognizes the columns by their heading, not by their position.
  3. Repeat the same with 2000000043 and paste into the Field sheet starting at A1. For very large field lists, you can filter the form to Class = Normal; FlowFields are skipped anyway.
  4. Save the workbook (.xlsx).

Notes:

  • Localized clients may export Enabled as Ja/Nein; both spellings are recognized.
  • Column headings are compared regardless of case, spaces, and punctuation (No. = No, Company Name = CompanyName).

Step 3 – Import

CLI
DataMigratePro.exe -t importsourcemetadata -i <Pfad>\SourceMetadataTemplate.xlsx [--dryrun] [--report <Pfad>\Bericht.csv]

The required connection parameters are the same as for --buildlocalmapping (SQL connection, --sourcedatabase, --mappingdatabase, --sourcecompany). The mapping database is created if necessary. In parallel with writing the tables and fields, BC Migration Dimension is populated from the dimension usage of the source company (see section 4a). An error there does not abort the import; it appears as a warning in the console, the editor summary, and the validation report.

Option Effect
-i <file.xlsx> Populated workbook (required)
--dryrun Only check and write the report; write nothing to the database
--report <file.csv> Path of the validation report; default C:\Migration\DataMigratePro\export\SourceMetadataImport_yyyyMMdd_HHmm.csv

Step 4 – Build the mapping

CLI
DataMigratePro.exe --buildlocalmapping
DataMigratePro.exe --buildmapping

If DataMigrate Pro detects a source with database version < 7.0 and finds imported metadata in the mapping database, the earlier approach using NAV objects (install_mapping / send_basemapping) is no longer needed. The regular post-processing steps run (Dimension Usage, configuration changes, transformers, real DB names, record counts, synchronization type), followed by Quick Auto Mapping, transformations, and, with --buildmapping, Save Configuration and Record Counts to Business Central.

4. Import rules

Rule Description
TableData only Object rows of other types (Table, Form, Report, …) are ignored.
Data per Company At least one row with Company Name ⇒ 1; otherwise 0.
System tables IDs ≥ 2000000000 and the tables excluded by the build mapping are skipped.
FlowField / FlowFilter Fields with Class = FlowField or FlowFilter are skipped (no SQL column).
Enabled = No Disabled fields are skipped (no SQL column).
Table must exist The physical table name (<Company>$<Name> or <Name>) is checked against sys.tables of the source database. If the table is missing, neither the table nor its fields are written (TableMissing).
Field must exist The field name is checked against INFORMATION_SCHEMA.COLUMNS (NAV name normalization, for example No. ↔ No_). If the column is missing, the field is not written (ColumnMissing).
Primary key Taken from the primary key constraint of the physical table.
Field type Source Field Type = Type Name (for example Code10); fallback Type + Len.
Record count Records is determined with COUNT(*) on the physical table; tables without records receive synchronization type 5.
Category As with the build mapping, through the TableClassifier from table number, name, and field names.

Repeatability

The import can be repeated any number of times:

  • New tables/fields are inserted.
  • Existing BC Migration Tables rows receive only Real DB Table Name, Data per Company, Records, and Fields (and Table Name, if empty). Type of synchronization, Category, Remarks, and so on remain unchanged.
  • Existing BC Migration Mapping rows are supplemented only in Real DB Field Name / Primary Key; destination table/field, Skip, Value Mapping Code, and so on are kept.

4a. Dimension usage (BC Migration Dimension)

NAV 2009 has no Dimension Set Entries yet; which dimension is used on which table is recorded in six usage tables. From these, DataMigrate Pro collects all used pairs of Table ID and Dimension Code, as the C/AL function UpdateDimensionUsage does, and writes them to BC Migration Dimension in the mapping database. The Origin Table field names the first table in this order in which the pair occurs:

Priority Source table (company prefix) Origin Table
1 Posted Document Dimension (359) Posted Document Dimension
2 Document Dimension (357) Document Dimension
3 Ledger Entry Dimension (355) Ledger Entry Dimension
4 Journal Line Dimension (356) Journal Line Dimension
5 Production Document Dimension (358) Production Document Dimension
6 G_L Budget Dimension (361) G/L Budget Dimension

In NAV 2009, G/L Budget Dimension has no Table ID column; its dimensions always belong to G/L Budget Entry, so Table ID = 96 is set for this table. Source tables without the required columns are skipped with a warning. If the update fails within --buildmapping / --buildlocalmapping, only a warning is issued and the remaining mapping steps continue.

Triggers:

Method Behavior
-t importsourcemetadata / Import source metadata from Excel (NAV 2009)… Runs in parallel with the table/field import (own SQL connection); not in a dry run.
-t updatedimensionusage / Update dimension usage (NAV 2009) Standalone update, for example after new postings in the source system.
--buildlocalmapping / --buildmapping Part of the post-processing, as before.

The update is incremental: new pairs are inserted, pairs that no longer occur are deleted, and a changed Origin Table is updated. Unchanged rows keep their rowversion, so the MappingEditor's SQL change detection transfers only real deltas to Business Central. In the editor, changed rows are placed in the propagation queue immediately after the action; on the command line, the transfer takes place with --buildmapping or -t saveconfiguration.

Source tables that do not exist in the source database are skipped and are named in the summary (Source tables not found: …). If all six are missing (NAV 2013 and later), BC Migration Dimension is emptied; there, the dimension usage comes from the regular mapping build.

Output (console and editor), for example:

Text
Dimension usage: 42 entries (Ledger Entry Dimension 12, Posted Document Dimension 30); 5 inserted, 0 deleted, 0 origin updated.

5. Validation report

The CSV report (;-separated, UTF-8 with BOM) contains one row per table and field:

Column Content
Level Table, Field, or Warning
Table No. / Table Name Source table
Field No. / Field Name Source field (for field rows)
Real DB Name Resolved physical table or column name
Status Write, TableMissing, ColumnMissing, SkippedFlowField, SkippedDisabled, SkippedSystemTable, SkippedExcluded, SkippedDuplicate, SkippedNoTable, NoFields
Message Reason

The console additionally shows a summary (valid / missing / skipped tables and fields) and the number of inserted and updated rows.

6. Exit codes

Code Meaning
0 Import or dry run successful; missing tables/fields are warnings in the report, not an error.
≠ 0 Hard errors: file not found, sheet or required column missing (Type, Company Name, ID, Name or TableNo, No., FieldName, Type, Class, Enabled), no connection to the source/mapping database.

7. Limitations

  • Source Option Value (OptionString) is not included in virtual table 2000000043 and remains empty.
  • Only the company configured through --sourcecompany is checked and counted; this also applies to the dimension usage.
  • -t buildsinglemapping still requires XML metadata and is not available for NAV 2009; instead, repeat the Excel import and run --buildlocalmapping.