Fast data import with BeyondDataImporter

Lets import Data in a minute

Daniel Gorski
Daniel Gorski 11. Juni 2024
2 Min. Lesezeit

BeyondDataImporter for Microsoft Dynamics 365 Business Central provides an interface called "BYD DI IProcessor" which allows for streamlined and efficient data import into Business Central tables.

Wondering how fast an implementation could be?

Write an enumextension:

enumextension 60000 "PC PostCode" extends "BYD DI Processor"
{
    value(60000; PostCode)
    {
        Caption = 'Post Code';
        Implementation = "BYD DI IProcessor" = "PC Post Code Processor";
    }
}

And implement the following interface:

interface "BYD DI IProcessor"
{
    procedure GetTableNo(): Integer;
    procedure GetTemplateFields(var Rec: Record "BYD DI Template Field" temporary);
    procedure OnChunkLoaded(Rec: Record "BYD DI Template"; Chunk: JsonArray);
    procedure OnImportFinished(Rec: Record "BYD DI Template");
}

Here’s a breakdown of the key components and functionalities:

1. Interface Implementation:

  • "BYD DI IProcessor" indicates that this codeunit conforms to the interface, requiring specific methods to be implemented for processing data.

2. Procedures and Functions:

  • GetTableNo(): Returns the ID of the "Post Code" table.
  • GetTemplateFields(...): Sets up the fields used in the import, including required/optional fields, and any relations.
  • OnChunkLoaded(...): Called when a chunk of data is loaded.
  • ProcessChunk(...): Processes each piece of the JSON data and maps it to the "Post Code" table.
  • OnImportFinished(...): Finalizes the import and reports created/updated records.

3. Data Processing:

  • ProcessChunk uses RecordRef and FieldRef to handle dynamic field assignment based on field type (Integer, Decimal, Boolean, Date, etc.).
  • Uses ConfigValidateMgt.EvaluateTextToFieldRef for type-safe conversion and validation.

4. Error Handling and Updates:

  • Checks for existing records by key (e.g. "Code" + "City") and updates or inserts as needed.
  • Tracks how many records were inserted/updated.

5. Performance Optimization:

  • Uses temporary tables and indirect references for efficient batch handling.
  • Ideal for large imports and background jobs.

And this is how it looks like:

Take our implementation code for free:

https://github.com/byndit/DataImporter-PostCode

Overall, the codeunit is designed for efficiency and flexibility, allowing easy adaptation for importing different datasets by merely implementing the necessary interface and adjusting field mappings and processing logic.

how-to
development
data import
business central
beyonddatimporter
json
interface
Modulare ERP-Architektur für skalierbare Unternehmenssoftware

Architektur

Mehr als nur Warenwirtschaft - die Landtechnik Lösung

ERP-Systeme wurden jahrelang als Monolithen verkauft. Die eigentliche Stärke moderner Plattformen wie Business Central liegt jedoch in der Modularität - und gen

Weiter lesen
Weiter lesen
BeyondCues Subscription Billing KPIs in Business Central

Product

Subscription Billing Meets Real-Time KPIs: BeyondCues Sub. Billing

MRR, ARR, ARPU und Churn Rate direkt im Role Center von Business Central - ohne AL-Entwicklung. BeyondCues Sub. Billing bringt Subscription-KPIs dorthin, wo Sie

Weiter lesen
Weiter lesen