Skip to content

Creating Data Mappings

A data mapping defines the connection between a specific area in Business Central, a document library, and the associated metadata. Only one mapping per area can be defined. The creation is based on the document type definition.

Returning codeunit text longer than 250 characters

This requires installed CORE and, for eDocuments, eDocuments versions that include the BLOB return methods below. The methods are not available in older symbols; update the app dependencies and symbols of your custom extension before using them.

For a text mapping of type CODEUNIT, call SetDynMappingReturnValueText on the SIM_CORE Temp Table buffer passed to your codeunit. CORE stores the complete result in the existing Return Value BLOB and reads it with GetDynMappingReturnValueText.

Rec.SetDynMappingReturnValueText(LocalResultText);

LocalResultText must be a Text variable without a fixed length and contain the complete calculated result. Do not shorten it with CopyStr or pass it through a Text[250] variable first. Call the setter after calculating the result; no Insert, Modify, or manual BLOB stream handling is required.

The BLOB result takes precedence when present. Without a BLOB result, the engine still reads the existing 250-character return field. Existing codeunits and the short-text examples below therefore remain supported. Both setters clear the legacy text field, so an explicitly empty result does not fall back to an earlier short value. UTF-8 text and line breaks are preserved.

The new return channel does not remove limits imposed by the receiving field or document format. Check data value formatting for a configured COPYSTR operation and validate the output against the actual XML schema and document profile. For example, verify the complete header reference in BuyerOrderReferencedDocument using a result longer than 250 characters, Unicode characters, line breaks, and an empty result.

For an eDocuments data value that uses a CORE data mapping, see Data Value Type: Data Mapping.

Steps to Create a Data Mapping

  1. Navigate to the administrator role center.

  2. In the menu, click “Mapping” and execute the “Data Mapping” action.

  3. Click “New” in the action bar to create a new mapping.

  4. Enter a code in the “Code” field.
    → This code uniquely identifies the mapping.

  5. Enter a description in the “Description” field.
    → The description should clearly and understandably identify the purpose of the mapping.

  6. Specify the target table in the “Target Table” field.
    → This is the original table the document should be linked to.

  7. Specify the target field in the “Target Field” field.
    → This is the field in the target table used for linking.

  8. Select the type in the “Type” field.
    → This defines how source and target fields are connected.

  9. Specify the source table in the “Source Table” field.
    → This is the table from which the value originates.

  10. Specify the source field in the “Source Field” field.
    → This field provides the value that will be linked to the target field.

Simple Actions

The following simple actions can be configured in the data mapping to get common values:

Function Name Description
USERID Returns the current user ID
USERFULLNAME Returns the full name of the current user
USERCONTACTEMAIL Returns the contact email address of the current user
CURRENTDATE Returns the current date
COMPANY Returns the current company name

to configure these actions follow these steps:

  1. Search for CORE Data Mapping
  2. Create a new CORE Data Mapping
  3. Define A CODE for the Data Mapping
  4. Enter the data mapping lines
  5. In the Type field, select FUNCTION
  6. In the Field Filter field, enter one of the above simple actions

Advanced Options

  • Apply filters:
    → If conditions are required for the mapping, a new line can be added.
    → The Type field can be set to FILTER or CONST.
    → The filter value is entered in the Field Filter field.
    → The filter applies to the specified source table and field.

  • Continue with another table:
    → To continue the mapping on another table, add a new line and enable the “New Table” checkbox.
    → The current Source Table becomes the new Target Table for the next line.

  • Finish with RETURN:
    → The last line must be added with the type “RETURN”.
    → This line returns the final value from the last source field to be used in the mapping.

In Document Dispatch, you can generate the complete placeholder value with your own AL logic. See Fill Document Dispatch Placeholders with a Custom Codeunit.