DocumentationDataMigrate ProMapping

DataMigrate ProMapping

Mapping Documentation

Mapping describes how DataMigrate Pro turns source tables and fields into destination fields. This page also explains the Mapping Editor.

This document describes how mappings are defined and used in DataMigrate Pro.

Mapping overview

Mappings describe how source tables and fields are transformed into destination fields. They are stored in the mapping database and can be generated or edited through the configuration workflows.

Mapping Editor UI (--editmapping)

The mapping editor can be started directly from CLI root mode:

PowerShell
DataMigratePro.exe --editmapping

This mode provides a dedicated desktop UI for mapping/configuration maintenance and follows the functional requirements documented in docs/Requirement-editmode-UI.md.

The editor navigation is organized into these core sections:

  • Migration Tables
  • Destination Tables
  • Value Mappings
  • Configuration

The navigation also exposes active filters, allows inline filter edits, and provides an All action to clear all active filters.

In-app Help Center

The editor includes a built-in Help section in the left navigation. It provides searchable explanations for every editor section (Migration Tables, Migration Mapping, Destination Tables, Value Mappings, Value Mapping Classification, Features, User Mapping, Merge sections, Configuration, Propagation Log), grid behavior, action bar commands, the action pane, mapping functions, dialogs (value mapping values, table/tablegroup selection, progress windows, calculated fields), the reconciliation window, and configuration workflows.

Press F1 or use the Help button in the content header to open context help for the current editor area. Dialogs and the standalone windows started with --reconcile and --editconfiguration open a separate, non-modal help window on F1 (or their Help button) so the article stays visible next to the dialog. Action pane buttons and grid actions offer Help for this action on right-click; the mapping functions menu contains a Help submenu with one entry per function.

Help articles include related-function links so users can move from an action to its prerequisites, follow-up actions, and similar workflows without leaving the GUI. Articles for GUI actions additionally show:

  • Command line – the equivalent DataMigratePro call (with a Copy button), for example -t putdata -s <TableNo> --automapping --changesonly 0 for Send Data.
  • Parameters and options – the relevant CLI options or dialog fields with their descriptions; required options are marked.
  • Further documentation – a link to the related docs/ document, published to the Azure deployment container by scripts/publish-docs.ps1 (deployment-files/docs/<name>.md plus referenced images and pre-rendered Mermaid diagrams; a PDF rendition is published alongside). Open downloads the Markdown and its images (authenticated, no public URL required) into %LOCALAPPDATA%\DataMigratePro\docs and renders them natively below the article (headings, lists, tables, code blocks, images, links); no browser, WebView2 runtime or PDF viewer is needed on the target machine. Text can be selected and copied, Ctrl + mouse wheel zooms. Links to other docs/*.md files open inside the viewer, #section links scroll to the heading, external links open in the default browser. A cached copy is reused on later requests, Reload forces a fresh download, Close hides the viewer.

The Command Line category contains the complete parameter reference: one article per -t task, one per root switch (for example --buildmapping), one per option group (connection, data and files, transfer and performance, mapping, value mapping, reconciliation, service, global switches), and an overview with exit codes. These articles are generated from DataMigratePro.Core/CommandCatalog.cs, which is also the source of DataMigratePro --help and DataMigratePro -t <task> --help. New tasks or options therefore need a description in CommandCatalog only; unit tests (CommandCatalogTests, MappingEditorHelpCatalogTests) fail when an entry of CommandMetadata is undocumented or a help topic references an unknown option.

Hand-written help content lives in DataMigratePro.MappingEditor/Models/HelpCatalog.*.cs (basics, sections, actions, dialogs). The topic list can be narrowed with the category filter and searched by title, text, option name (for example --changesonly) or dialog name.

Grid sorting and filtering

All relevant grids support header sorting and column-level filtering.

Selected rows use the same blue highlight with white text, including drilldown links, regardless of alternating row colors or keyboard focus. Text input controls retain dark text on their light editing background. Normal alternating and status colors return when rows are deselected.

Supported filter expression styles:

  • Exact value match
  • Numeric range: n..m (inclusive)
  • OR pattern: a|b
  • Wildcard pattern: *text

Filter behavior guidelines:

  • Whitespace around operators is ignored.
  • Invalid filter syntax shows a validation hint and must not crash the UI.
  • Numeric-only operators on non-numeric columns should show a meaningful warning.

Rendering and edit semantics for key fields

The following render rules apply in mapping-focused grids:

  • Category (in BC Migration Tables) is rendered as a dropdown over the category enum values.
  • Type of synchronization is rendered as a dropdown over synchronization type values.
  • Skip is rendered as a checkbox mapped to 0/1 storage semantics.

For Migration Tables list behavior:

  • Sequence in Category is hidden.
  • Records, Fields, and Mapped Fields are read-only informational columns.
  • Fields and Mapped Fields provide drilldown into filtered BC Migration Mapping rows.

Editable columns in Migration Tables are limited to:

  • Category
  • Type of synchronization
  • Synch. Table No.
  • Synchronize to Database
  • Remarks

Lookup, auto-fill, and dependent updates

The editor supports lookup-window selection plus manual entry for critical mapping fields.

In Migration Mapping:

  • Destination Table No. is a plain number field, like Synch. Table No. in Migration Tables. The destination table name is visible and read-only, filled automatically from BC Table.
  • The adjacent ... button opens the same filterable table-selection window (Table No., Table Name). Select, Enter or double-click applies a table; Cancel keeps the previous value.
  • The list starts with 0 - (no destination table). Selecting a table or entering a valid number resets the destination field number, name and type and sets Skip = 1; 0 also clears the destination table name.
  • Unknown table numbers are rejected with a message: the previous table number and name are restored, existing field assignments and pending row edits are preserved, and the rejected edit is neither saved nor propagated.
  • Destination Field No. is a plain dropdown (no autocomplete) resolving against BC Field, filtered by selected destination table, and auto-fills destination field name. The list only offers fields not yet assigned in other mapping rows of the same destination table, keeps the row's current field, and starts with a (no destination field) entry that clears the assignment.
  • Invalid or empty destination field selection sets Skip = 1; valid selection clears Skip = 0.
  • Join-related columns remain visible in-grid: Joined Table, Join Clause, Where Clause.
  • Value Mapping supports lookup selection and direct assignment.

In Migration Tables:

  • Synch. Table No. is a plain number field; the table number alone identifies the table and Synch. Table Name is refreshed from BC Table automatically.
  • The ... button next to it opens a table-selection popup listing BC Table (Table No., Table Name) with the same column filter syntax as the grids (n..m, >n, a&b, a|b, @text, *).
  • The list starts with 0 - (no synchronization table). Selecting it, or entering 0, clears the synchronization table number and name. Resetting a previously positive number also clears destination table and field assignments in the related mappings and sets their Skip flag to 1; the reset is saved and propagated through the normal update workflow.
  • A table number that does not exist in BC Table is rejected: a hint is shown, the previous value is restored and nothing is saved or propagated.
  • Selecting a table (from 0 or from another table) auto-matches the related BC Migration Mapping rows against the new destination table.
  • Add Calculated Table (grid action, enabled for a selected positive table row) clones the selected source table under a negative Table No. so the same physical source table can be mapped to a second destination table (the pattern used by the FinancialReport transformer: 84 → BC 84 and −84 → BC 88). The dialog proposes -<Table No.>; any other free negative number can be entered. The new row copies the table settings and Real DB Table Name, Synch. Table No. starts at 0, and the positive source fields of the template are copied into BC Migration Mapping with empty destination assignments and Skip = 1; calculated fields (negative Source Field No.) of the template are not copied. Set Synch. Table No. on the new row to auto-match the copied fields, then add calculated fields in Migration Mapping as needed. Table and mapping rows are queued for Business Central synchronization.
  • Delete Calculated Table (enabled only for a selected negative Table No.) deletes the calculated table together with all of its mapping rows and queues the deletions for Business Central. Regular source tables cannot be deleted this way.
  • Send Data, Send Remaining, Delete Data and the remaining-record counters work for calculated (negative) tables like for regular tables.

Propagation and persistence expectations

  • Changes should be propagated automatically to Business Central when a transfer target is available.
  • Save failures should keep pending changes in the UI and surface actionable error information.
  • Filter presets are persisted per user profile and can be saved, applied, overwritten, and deleted.

Propagation of SQL-side changes

Changes made directly in SQL (outside the editor) are detected on editor startup and queued through the same propagation queue. The mechanism mirrors the Navision transfer tables:

  • Tracked tables: BC Migration Tables, BC Migration Mapping, BC Migration Dimension, BC Value Mapping, BC Value Mapping Value. Each table carries a [timestamp] rowversion column; tables created before the column existed receive it automatically on the next mapping initialization or editor start (ALTER TABLE … ADD [timestamp]). A table that already has a rowversion column under a different name is skipped with a warning.
  • Snapshot tables <table>$Transfer (mapping database, primary-key columns + [timestamp] bigint + [DMPSystemDateTime]) record the rowversion last delivered to Business Central.
  • Startup compares each row with its snapshot: rows whose rowversion differs or is missing are queued with reason sql-change (full row payload), rows present in the snapshot but missing in the table are queued with reason sql-delete (__action = 2). The queued counts appear in the navigation footer and the entries in the Propagation Log.
  • When a $Transfer table is created for the first time it is baselined with the current content, so existing installations start with "everything transferred" and only subsequent changes are propagated.
  • Each queue item stores the rowversion captured at enqueue time (SourceRowVersion). After a batch succeeds the snapshot is updated with that rowversion (or the row is removed for deletions), so editor-made changes are also recorded and not re-sent on the next start.
  • Receive configuration, Send configuration and Collect structure data (full buildmapping incl. saveconfiguration) re-baseline all snapshots afterwards because these operations touch every row (received rows would otherwise be echoed back to Business Central).
  • Command-line runs (buildmapping, saveconfiguration, getdata on configuration tables) do not re-baseline; their changes are detected and queued on the next editor start.

Troubleshooting:

  • Emptying a $Transfer table (TRUNCATE TABLE [dbo].[BC Migration Mapping$Transfer]) forces a full resend of that table on the next editor start.
  • Dropping a $Transfer table recreates it with a fresh baseline (nothing is resent).

Settings maintenance from editor

The editor includes a configuration area to edit connection-relevant settings.json values (database and Business Central connection settings), with validation before persistence.

Calculation field

The Calculation column allows SQL expressions to transform source data. Expressions are injected into generated SQL and can reference the source table alias T and join aliases (T18, T42, etc.).

The SQL mapping column supports at least 300 characters. Mapping initialization and configuration-change imports automatically widen existing varchar(250) columns to varchar(300) without deleting or truncating stored values. Existing wider columns (including MAX) are not reduced; Unicode type, nullability, and collation are preserved. Configuration metadata and editor SQL parameters also support 300 characters. This does not change a separate Business Central app's field definition.

Missing columns during configuration-change import

Both online and local-file imports of ConfigurationChanges.json validate Calculation references against the actual source schema before writing field changes. This includes the main source projection (T, including available extension fields) and explicitly configured join aliases. Only references to demonstrably missing columns are replaced with the SQL literal NULL; existing references, string literals, comments, and the surrounding expression remain unchanged.

If ConfigurationChanges.json contains several entries for the same source table/field, only the last entry is applied (matching the result of sequential updates) and a warning … duplicate entries in ConfigurationChanges.json, only the last one is applied. is logged. Earlier duplicates are discarded before validation, so a calculation such as T36.[…] from a superseded entry can no longer fail with Calculation alias 'T36' has no unambiguous join definition when the final entry carries no join.

Join definitions are collected from non-skipped mapping rows of the source table plus the rows written by the import itself. A row that an earlier run auto-marked with Skip = 1 (for example Auto-marked Skip=1: destination field not found in BC Field on a custom table) therefore still provides the join its own calculation references, so re-applying 22218/-5 with T17.[Amount] and Joined Table = 17 no longer aborts --buildmapping with Calculation alias 'T17' has no unambiguous join definition for source table 22218. Skipped rows that are not part of the import remain excluded.

For example, when T.[Source Code] is absent but T1234.[Source Code] exists:

SQL
-- Before import
CASE WHEN T.[Type]=1 THEN T1234.[Source Code] ELSE T.[Source Code] END

-- Stored Calculation
CASE WHEN T.[Type]=1 THEN T1234.[Source Code] ELSE NULL END

Each replacement is logged with its source table/field context. Join definitions applied by the same import are considered regardless of their order in the JSON file. Unknown aliases, conflicting join definitions, unreadable schemas, or unsupported multipart references stop the import with an explicit error rather than silently substituting NULL. Field and table changes are written transactionally after validation. Join Clause expressions are not repaired, and calculations already stored in the database are not rewritten unless included in the import.

Optional SQL integration tests use DMP_TEST_SQL_CONNECTION_STRING pointing to an isolated test instance. They create and remove uniquely named test databases to verify column widening, idempotency, preserved values and metadata, and storage of a 300-character expression. Without this variable, these tests are skipped.

Placeholders

The following placeholders are supported in Calculation expressions:

  • {Company} → replaced with the source company name.
  • {FieldName} → replaced with the current Source Field Name, including brackets.

{Company} can also be used in Join Clause expressions to limit results in company-spanning tables (tables that contain data for multiple companies). This ensures joins only pick rows for the active source company.

Example (remove domain + \ from a user id field):

Text
CASE WHEN CHARINDEX('\\',T.{FieldName})>0 THEN SUBSTRING(T.{FieldName}, CHARINDEX('\\',T.{FieldName})+1,100) ELSE T.{FieldName} END

If Source Field Name is User ID, the generated SQL becomes:

Text
CASE WHEN CHARINDEX('\\',T.[User ID])>0 THEN SUBSTRING(T.[User ID], CHARINDEX('\\',T.[User ID])+1,100) ELSE T.[User ID] END

If Calculation is empty, the field is selected as T.[User ID].

Source Field Name

The Source Field Name column must match the field name in the source table. It is used for:

  • direct field selection when no calculation is provided
  • {FieldName} placeholder expansion

Where Clause

The Where Clause column allows row-level filtering in generated SQL. Use it to migrate only records that match specific conditions.

The expression is injected into the source query and can reference the source table alias T and join aliases (T18, T42, etc.).

Typical usage

  • limit migrated records to active or relevant data
  • exclude invalid or placeholder values
  • combine with Join Clause for company-specific filtering

Example:

Text
T.[Notify] = 1 AND ISNULL(T.[To User ID], '') <> ''

Generated SQL (excerpt):

Text
FROM [Demo Database NAV (6-0)].dbo.[Record Link] T
WHERE T.[Notify] = 1 AND ISNULL(T.[To User ID], '') <> ''

Example (Item table, option field Status):

Text
T.[Status]<>3

In this example, option value 3 means Inactive, so the filter excludes inactive items.

Generated SQL (excerpt):

Text
FROM [Demo Database NAV (6-0)].dbo.[Item] T
WHERE T.[Status]<>3

Example: {Company} in Join Clause + Calculation

The following mapping rows demonstrate how {Company} is used in the Join Clause to filter company-spanning tables, how Calculation can concatenate fields, and how Where Clause can restrict migrated records.

Configuration (excerpt):

Row 1 (URL1)

Column Value
Source Table No. 2000000068
Source Table Name Record Link
Source Field No. 3
Source Field Name URL1
Source Field Type Text
Destination Table No. 2000000068
Destination Table Name Record Link
Destination Field No. 3
Destination Field Name URL1
Destination Field Type Text2048
Skip No
Primary Key No
Joined Table 0
Join Clause
Where Clause T.[Notify] = 1
Calculation T.[URL 1]+T.[URL 2]+T.[URL 3]

Row 2 (Company)

Column Value
Source Table No. 2000000068
Source Table Name Record Link
Source Field No. 12
Source Field Name Company
Source Field Type Text
Destination Table No. 2000000068
Destination Table Name Record Link
Destination Field No. 12
Destination Field Name Company
Destination Field Type Text30
Skip No
Primary Key No
Joined Table 2000000006
Join Clause T2000000006.[Name]='{Company}'
Where Clause T.[Notify] = 1
Calculation

Generated SQL (excerpt):

Text
;WITH T AS (
	SELECT CAST(SUBSTRING(CAST(T.[timestamp] AS VARBINARY(8000)), 1, 8) AS BIGINT) AS [timestamp],
		   ROW_NUMBER() OVER(ORDER BY T.[Link ID]) [RowNumber],
		   T.[Link ID] AS [Link ID],
		   T.[Record ID] AS [Record ID],
		   T.[URL 1]+T.[URL 2]+T.[URL 3][URL1],
		   T.[Description] AS [Description],
		   T.[Type] AS [Type],
		   T.[Note] AS [Note],
		   LEFT(CONVERT(varchar(50), CASE WHEN ISDATE(T.[Created]) = 1 AND T.[Created] NOT IN ('1753-01-01', '1900-01-01') THEN CAST(T.[Created] AS datetime) ELSE NULL END, 127), 19) AS [Created],
		   T.[User ID] AS [User ID],
		   T.[Company] AS [Company],
		   T.[Notify] AS [Notify],
		   T.[To User ID] AS [To User ID]
	FROM [Demo Database NAV (6-0)].dbo.[Record Link] T
	JOIN [Demo Database NAV (6-0)].dbo.[Company] T2000000006 WITH (NOLOCK) ON T2000000006.[Name]='CRONUS AG'
	WHERE T.[Notify] = 1
)
SELECT T.*, 0 [Type_of_Change]
FROM T
WHERE T.[RowNumber] BETWEEN 1 AND 10000000

How it comes together:

  • The Join Clause uses {Company} so the join is scoped to the active source company. At runtime, {Company} is replaced with the source company name (here: CRONUS AG).
  • The Joined Table value 2000000006 results in a join alias T2000000006, which is referenced in the join clause.
  • The Where Clause filters the source rows before final paging/selection, so only matching records are migrated.
  • The Calculation concatenates three source fields into one destination field (URL1).

Value mapping

Eine Schritt-für-Schritt-Erklärung zur neuen Value-Mapping-Klassifizierung und zur optionalen Vorbefüllung aus den Quelldaten steht in Value-Mapping-Klassifizierung.md.

Audit evidence: DataMigratePro -t mappingreport writes a printable report of all mappings actually used – including the meaning of Joined Table/Join Clause, Calculation and Value Mapping per field, the complete value lists and the SalesPrice feature transition. See DataMigratePro-Reconciliation-Dokumentation.md section 14.

Value mapping replaces a source value with a destination value based on a mapping code. It uses the BC Value Mapping and BC Value Mapping Value tables and is activated per field via the Value Mapping Code column in BC Migration Mapping.

Maintaining values via CSV template (Mapping Editor)

In the Mapping Editor, open the values of a mapping code (Value Mappings → details, or the Value Mapping Code lookup in Migration Mapping). The values dialog offers two file actions next to Save:

  • Export template (CSV) writes a UTF-8 CSV file (ValueMapping_<CODE>.csv) with the header Source Value;Destination Value followed by the current rows. Open it in Excel, fill in or correct the destination values, and save it again as CSV.
  • Import CSV reads such a file back into the dialog. Rows are matched by Source Value (case-insensitive): existing rows get their Destination Value updated, unknown source values are appended, rows with an empty Source Value are skipped. Rows that are not in the file remain unchanged.

Import rules:

  • The delimiter is detected automatically (;, ,, tab or |); quoted fields ("a;b", "" for a literal quote) are supported.
  • A header row is optional. If present, columns are resolved by name (Source/Quelle and Destination/Target/Ziel); otherwise the first column is the source value and the second the destination value.
  • Imported rows are only persisted when the dialog is closed with Save; dispatcher validation applies as usual.

Example: Language Code (table 18 / Customer)

Configuration (excerpt):

Table Column Value
BC Migration Mapping Source Table No_ 18
BC Migration Mapping Source Field Name Language Code
BC Migration Mapping Value Mapping Code LANGUAGE
BC Value Mapping Code LANGUAGE
BC Value Mapping Value Value Mapping Code LANGUAGE
BC Value Mapping Value Source Value ENU
BC Value Mapping Value Destination Value ENG

Generated SQL (excerpt):

Text
;WITH T AS (
	SELECT CAST(SUBSTRING(CAST(T.[timestamp] AS VARBINARY(8000)), 1, 8) AS BIGINT) AS [timestamp], 
		   ROW_NUMBER() OVER(ORDER BY T.[No_]) [RowNumber], 
		   T.[No_] AS [No_],
		   T.[Name] AS [Name],
		   VM1.[Destination Value] AS [Language Code]
	FROM [Demo Database NAV (6-0)].dbo.[CRONUS AG$Customer] T
	LEFT JOIN [Demo Database NAV (6-0)].dbo.[BC Value Mapping Value] VM1 ON VM1.[Value Mapping Code] = 'LANGUAGE' AND VM1.[Source Value] = T.[Language Code]
)
SELECT T.*, 0 [Type_of_Change]
FROM T

How it comes together:

  • The Value Mapping Code on the mapping row causes the query generator to add a LEFT JOIN to BC Value Mapping Value.
  • The field projection switches from T.[Language Code] to VM1.[Destination Value] and keeps the original destination field name.
  • If the value mapping tables are missing or empty, the join is not added and the source value is selected directly.

Example: Dimension mapping (Dimension Code present)

If the BC Value Mapping record has a Dimension Code, the mapping is applied in the dimension CTE instead of via a join.

Configuration (excerpt):

Table Column Value
BC Migration Dimension Table ID 21
BC Migration Dimension Dimension Code DEPARTMENT
BC Value Mapping Code DEPT
BC Value Mapping Dimension Code DEPARTMENT
BC Value Mapping Value Value Mapping Code DEPT
BC Value Mapping Value Source Value SALES
BC Value Mapping Value Destination Value SAL

Generated SQL (excerpt):

Text
;WITH T AS (
	SELECT ...
), D AS
(
   SELECT T.[Entry No_],
		  MAX(COALESCE(CASE WHEN [Dimension Code]='DEPARTMENT' THEN
			  (SELECT TOP 1 VMV.[Destination Value]
			   FROM [Demo Database NAV (6-0)].dbo.[BC Value Mapping Value] VMV
			   WHERE VMV.[Value Mapping Code]='DEPT'
				 AND VMV.[Source Value]=T.[Dimension Value Code])
		  ELSE '' END,'')) [DimensionValue(DEPARTMENT)]
	 FROM [Demo Database NAV (6-0)].dbo.[CRONUS AG$Dimension Set Entry] T
	WHERE [Table ID]=21
 GROUP BY T.[Entry No_]
)
SELECT T.*, D.[DimensionValue(DEPARTMENT)]
FROM T
LEFT JOIN D ON T.[Entry No_]=D.[Entry No_]

How it comes together:

  • The Dimension Code on BC Value Mapping links the mapping to a dimension.
  • The generator injects a subquery into the dimension CTE to translate dimension values.
  • If no mapping exists for a specific source value, the expression yields an empty string for that dimension value.

Example: Conditional value mapping (Condition Field present)

Sometimes the translation of a field depends on the value of another field in the same row. In Sales Line (table 37) the field No. refers to a G/L account, an item or a resource depending on Type, so each case needs its own value mapping.

This is solved with a dispatcher value mapping: a BC Value Mapping record with a Condition Field No. / Condition Field Name. Its values do not translate data; instead each row maps a value of the condition field (Source Value) to the code of the value mapping that should be applied (Destination Value). * as Source Value defines the default (ELSE) mapping.

The target mappings (GLACCOUNT, ITEM, RESOURCE) are ordinary value mappings without a condition and can be reused unchanged in the G/L Account, Item and Resource tables.

Configuration (excerpt):

Table Column Value
BC Migration Mapping Source Table No_ 37
BC Migration Mapping Source Field Name No.
BC Migration Mapping Value Mapping Code SL_NO
BC Value Mapping Code SL_NO
BC Value Mapping Condition Field No. 5
BC Value Mapping Condition Field Name Type
BC Value Mapping Value SL_NO / Source Value / Destination Value 1 → GLACCOUNT
BC Value Mapping Value SL_NO / Source Value / Destination Value 2 → ITEM
BC Value Mapping Value SL_NO / Source Value / Destination Value 3 → RESOURCE
BC Value Mapping Code GLACCOUNT (no condition)
BC Value Mapping Value GLACCOUNT / Source Value / Destination Value 8100 → 6100
BC Value Mapping Code ITEM (no condition)
BC Value Mapping Value ITEM / Source Value / Destination Value 1000 → A-1000
BC Value Mapping Code RESOURCE (no condition)
BC Value Mapping Value RESOURCE / Source Value / Destination Value LINDA → R-LINDA

Generated SQL (excerpt):

Text
;WITH T AS (
	SELECT ...,
		   T.[Type] AS [Type],
		   COALESCE(VM1.[Destination Value], CONVERT(nvarchar(4000), T.[No_])) AS [No_]
	FROM [Demo Database NAV (6-0)].dbo.[CRONUS AG$Sales Line] T
	LEFT JOIN [MappingDb].dbo.[BC Value Mapping Value] VM1
		ON VM1.[Value Mapping Code] = CASE CONVERT(nvarchar(4000), T.[Type]) WHEN '1' THEN 'GLACCOUNT' WHEN '2' THEN 'ITEM' WHEN '3' THEN 'RESOURCE' END
	   AND VM1.[Source Value] = CONVERT(nvarchar(4000), T.[No_])
)
SELECT T.*, 0 [Type_of_Change]
FROM T

How it comes together:

  • The Condition Field No. marks SL_NO as a dispatcher. Its values become the CASE expression that selects the effective Value Mapping Code per row; a single LEFT JOIN is enough.
  • The condition column is resolved from the source table: first via the mapped source field with the same Source Field No., otherwise via Condition Field Name. If it cannot be resolved, a warning is logged and the field is passed through unchanged.
  • Rows whose condition value has no rule (e.g. Type = 4 / Fixed Asset) and rows whose value is missing in the selected target mapping keep the original value (COALESCE).
  • Comparison is textual: option fields are compared with their integer value ('1', '2', …), code fields with their text.
  • A dispatcher cannot be combined with a Dimension Code, and dispatchers cannot point to other dispatchers.
  • In the Mapping Editor, the Create Value Mapping dialog offers the source fields of the current table as Condition Field; the values dialog of a dispatcher offers the existing value mapping codes as Destination Value and warns about unknown codes on save.
  • The columns Condition Field No_ / Condition Field Name are added to BC Value Mapping automatically (fields 5 and 6 in the BC table). Mapping databases without these columns keep working; value mappings then behave as plain mappings.

Why Table No. is configurable

Table No. scopes a value mapping to a specific source table. This avoids accidental reuse of a mapping code across tables that use the same values but require different target values.

Example: Same code, different targets per table

Configuration (excerpt):

Table Column Value
BC Value Mapping Code STATUS
BC Value Mapping Table No. 18
BC Value Mapping Value Source Value B
BC Value Mapping Value Destination Value Blocked
BC Value Mapping Code STATUS
BC Value Mapping Table No. 23
BC Value Mapping Value Source Value B
BC Value Mapping Value Destination Value Inactive

How it comes together:

  • Table 18 (Customer) uses STATUS to translate B → Blocked.
  • Table 23 (Vendor) can use the same STATUS code but translate B → Inactive.
  • Without Table No., both tables would share the same mapping and the translation could be wrong for one of them.

Next steps

  • Add examples for joins and value mappings
  • Document mapping table columns and constraints