web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

I need some sample about Customizing Synchronization events in MS documentation

(6) ShareShare
ReportReport
Posted on by 29
I'm using BC Data-Sync Dataverse Connector Setup.
In Microsof documentation the "Customizing Synchronization" section doesn't provide any sample about using trigger events in CodeUnit  (5345) "Integration Rec. Synch. Invoke".
I didn't find any blog or post about the events.
 
Could someone kindly post some examples with AL code here, please?
 
Thanks!
 
I have the same question (0)
  • Suggested answer
    YUN ZHU Profile Picture
    95,729 Super User 2025 Season 2 on at
    Hi, hope the following can give you some hints.
    Dynamics 365 Business Central: Customizing an Integration with Microsoft Dataverse (Integrate custom tables)
     
    Thanks.
    ZHU
  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    8,760 on at

    Hi,

    You're asking for AL code samples that show how to customize synchronization using events from Codeunit 5345 "Integration Rec. Synch. Invoke", especially since MS documentation doesn’t include examples.

    You're absolutely right while the docs list the available events, they don’t walk through how to use them in practice.

    Here’s a working example to help you get started:

    Sample: Using OnBeforeTransferRecordFields to intercept field mapping
    al
    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Integration Rec. Synch. Invoke", 'OnBeforeTransferRecordFields', '', true, true)]
    local procedure HandleOnBeforeTransferRecordFields(SourceRecordRef: RecordRef; var DestinationRecordRef: RecordRef)
    var
        SourceContact: Record Contact;
        DestContact: Record Contact;
    begin
        if SourceRecordRef.Number = Database::Contact then begin
            SourceContact.Get(SourceRecordRef.RecordId);
            DestContact.Get(DestinationRecordRef.RecordId);
    
            // Example: Override a field before transfer
            DestContact."Your Custom Field" := SourceContact."Your Custom Field";
            DestContact.Modify();
        end;
    end;
     

    This lets you intercept the synchronization process and apply custom logic before fields are transferred. You can also use OnAfterTransferRecordFields if you want to validate or log changes after the sync.


    Other useful events in Codeunit 5345
    • OnBeforeInsertRecord – customize behavior before inserting a new record
    • OnAfterInsertRecord – apply logic after a record is created
    • OnBeforeModifyRecord – intercept updates before they’re applied
    • OnUpdateConflictDetected – handle sync conflicts gracefully
    • OnBeforeApplyRecordTemplate – override template logic during sync


    These events give you full control over how records are created, updated, and matched between Business Central and Dataverse.


    Here’s a helpful link showing how to configure and extend Dataverse synchronization using AL events:

    Customizing an Integration with Microsoft Dataverse – Microsoft Learn
    Codeunit 5345 Event Reference – Microsoft Learn
    Dynamics 365 Lab – Custom Table Integration Walkthrough


    If you find this helpful, feel free to mark this as the suggested or verified answer.

    Cheers
    Jeffrey

  • David Pezzoli Profile Picture
    14 on at
    Hi all,
    Could you also provide an AL example using the 'OnBeforeInsertRecord' or 'OnAfterInsertRecord' event, please?
     
    Thank you!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,664

#2
YUN ZHU Profile Picture

YUN ZHU 960 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans