Mapping Codeunits
- How do I open the mapping codeunits?
- What additional information is available on parameters?
Tip
Summary: Mapping Codeunits are Microsoft Dynamics 365 Business Central objects that can execute source code, allowing for an interface to its own source code. The Codeunits page allows the user to fill in fields as necessary. Additionally, parameters such as REOPEN, POST, ITEMTRACKING, DIMSETID, SETENTRYRECORD, BREAKLOOP, and COMMIT can be defined and used. Custom codeunits can also be called with the OnBeforeCodeunitParameter(Rec) event.
Mapping Codeunits are Microsoft Dynamics 365 Business Central Objects that can execute source code. Therefore, an interface to its own source code is possible. Any number of Codeunits can be stored for one Mapping Line.
To open the mapping codeunits
- Choose Codeunits in the Lines FastTab of the Mapping Version Card to access the Codeunits page.
- On the Codeunits page, fill in the fields as necessary. Hover over a field to read a short description.
Additional information on parameters
You can define additional Parameters for DIS Codeunits.
Technically, a Codeunit.RUN is performed. Codeunit 5100957, DIS - Mapping Codeunit Mgt., is special in that it can transfer additional parameters. Choose the Set DIS Codeunit action to automatically enter this codeunit in the Codeunit No. field on the current line. The following Parameters are available:
REOPEN – This parameter sets the status of a Microsoft Dynamics 365 Business Central document to Open. The Repository of the Mapping Line must be equal to the Sales Header or Purchase Header.
POST – This parameter posts the Microsoft Dynamics 365 Business Central document. Before posting, a COMMIT is performed, and then for each billing line and delivery line, a Type of Change = Insert is processed. The Repository of the Mapping Line must be equal to the Sales Header, Purchase Header or Service Header. For Service Header, the type type of posting can be controlled via the variables Ship, Invoice and Consume, each with the constant values true or false.
ITEMTRACKING – This parameter reads or writes the item tracking of a document or a line.
If the parameter is processed for a Mapping Line, like Sales Header or Purchase Header, the complete item tracking of a Microsoft Dynamics 365 Business Central document is written to the Repository and entered in the Item Tracking Repository Field field of the Mapping Version. The Repository Type should be Table with the selection Temporary Table and Table No. 336 (Tracking Specification).Note
The (temporary) Repository must be exported afterwards.
To read item tracking, the parameter must be executed for a Mapping Line with Repository Type = Table, like Sales Line or Purchase Line. A temporary table with Table No. 336 should be populated with all relevant information. The Repository Code of the temporary table must be entered in the Item Tracking Repository Code field of the Mapping Version.
DIMSETID – This parameter is used for a Mapping Line with a Repository of type temporary Table and Table No. 480 (Dimension Set Entry). The Dimension Set Id is calculated from the table entries and written to the DimSetId parameter. Subsequently, all records in the temporary table are removed.
SETENTRYRECORD – This parameter writes the current Record of the Microsoft Dynamics 365 Business Central Table to a Mapping Entry, and therefore the Partner Message. Choose the Open Document action in the Sent/Received Messages to find and open the message.
BREAKLOOP – This parameter cancels the current loop at the end of the Line Action. Therefore, the number of records per XML or JSON file can be managed (see Limit Number of Records per XML Document).
COMMIT – This parameter processes a COMMIT that saves all database transactions in Microsoft Dynamics 365 Business Central, even if an error occurs.
ERROR – This parameter triggers an error during the mapping processing. The error message is defined by the constant ErrorText variable (see Mapping Variables). When an error occurs, the processing of the current record is stopped, and the error is displayed in the Mapping Entries. The error is only triggered if the ErrorText variable has a value.
Custom Codeunits - Custom codeunits can be called by parameters as well. If a parameter is set in the configuration, the codeunit must have table 5100965, DIS - Mapping Codeunit as the SourceTable property. The field is now editable on the page, not only if the default codeunit is selected. By default, the lookup will only show the supported parameters.
Additionally, the OnBeforeCodeunitParameter(Rec) event is called with Codeunit 5100957, DIS - Mapping Codeunit Mgt. Own source code can be added to produce own calculations with own parameters.
Feedback
Submit feedback for this page .