Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Business Central / Dataverse Integration - Custom Fields

Posted on by 26

I'm attempting to synch custom fields in Business Central with custom fields in the Dataverse used by D365 for Sales. I'm able to create the custom fields using AL code in BC and customizations in D365. I'm also able to create new Integration Field Mapping records in the Integration Table Mapping area for Customers.

I followed these articles to get me this far:

Customizing an Integration with Microsoft Dataverse - Business Central | Microsoft Docs

Using AL Table Proxy Generator Tool to create Integration Table(s) in Business Central for the Dataverse table – ARKSD Consultancy Private Limited

 

Below is a code snippet of 2 fields I want to create an integration field mapping record for:

 

InsertIntegrationFieldMapping(

        IntegrationTableMappingName,

        Customer.FieldNo("Chapter"),

        CDSAccount.FieldNo("new_chapter"),

        IntegrationFieldMapping.Direction::FromIntegrationTable, '', true, false);

 

InsertIntegrationFieldMapping(

        IntegrationTableMappingName,

        Customer.FieldNo("Category"),

        CDSAccount.FieldNo("AccountCategoryCode"),

        IntegrationFieldMapping.Direction::FromIntegrationTable, '', true, false);

 

The procedure called by these 2 field mappings is this –

 

procedure InsertIntegrationFieldMapping(IntegrationTableMappingName: Code[20]; TableFieldNo: Integer; IntegrationTableFieldNo: Integer; SynchDirection: Option; ConstValue: Text; ValidateField: Boolean; ValidateIntegrationTableField: Boolean)

    var

        IntegrationFieldMapping: Record "Integration Field Mapping";

    begin

        IntegrationFieldMapping.CreateRecord(IntegrationTableMappingName, TableFieldNo, IntegrationTableFieldNo, SynchDirection,

            ConstValue, ValidateField, ValidateIntegrationTableField);

    end;

  

Both of the field mappings get created in the integration mapping table but a problem occurs with the “Chapter” field.

If I just create “Category” mapping a custom BC field (Category) with an out-of-the-box D365 field (AccountCategoryCode), I am able to couple a Customer/Account pair and sync data.

 fieldmapping1.png

If I also create the “Chapter” mapping a custom BC field (Chapter) with a custom D365 field (new_chapter), I am NOT able to couple Customer/Account records and sync.

 fieldmapping2.png

couplingerror.png

I am including some snapshots of what the mapping table looks like with just Category created and with both Category and Chapter created and an error message that is displayed when attempting to couple. One thing I noticed is that the Integration Field Name is blank for Chapter but does show an Integration Table Field No. of 10019 which was generated with the AL Table Proxy Generator tool. Below is the entry in the generated file.

 

field(10019;new_Chapter;Text[20])

    {

      ExternalName = 'new_chapter';

      ExternalType = 'String';

      Description = 'This is a chapter field';

      Caption = 'Chapter';

    }

 

It appears the custom D365 (DataVerse) field does not exist or cannot be resolved but the generator tool clearly sees the field and added to the file so that I could reference it in code. I also see the custom field (new_chapter) in their D365 instance. The D365 database is the same as the DataVerse correct? I’m not sure where the disconnect may be but any help is appreciated.

  • Suggested answer
    Jazzy Profile Picture
    Jazzy 5 on at
    RE: Business Central / Dataverse Integration - Custom Fields

    This worked for me. I needed to set /tabletype:CRM when running altpgen.exe.

  • Suggested answer
    Greg Enns Profile Picture
    Greg Enns 1,102 on at
    RE: Business Central / Dataverse Integration - Custom Fields

    @Erik Hougaard explains it well in this video: www.youtube.com/watch

  • Jazzy4321 Profile Picture
    Jazzy4321 26 on at
    RE: Business Central / Dataverse Integration - Custom Fields

    I think this may be the step I'm missing. How do you generate an updated definition of the "Dataverse Account" table in BC?

  • Suggested answer
    Greg Enns Profile Picture
    Greg Enns 1,102 on at
    RE: Business Central / Dataverse Integration - Custom Fields

    Did you generate an updated definition of the "Dataverse Account" table in BC? This "integration table" or "proxy table" must have the same definition as the table in Dataverse in order for AL code to interact with the actual dataverse table.

  • Suggested answer
    YUN ZHU Profile Picture
    YUN ZHU 73,472 Super User 2024 Season 2 on at
    RE: Business Central / Dataverse Integration - Custom Fields

    Hi, hope the link below will give you some hints.

    https://yzhums.com/17065/

    Thanks.

    ZHU

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans