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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

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

Map ParentAccountId from CRM Account to Business Central

(5) ShareShare
ReportReport
Posted on by 24
Hi.  We have Business Central Saas with connected to CRM.   The mapping are mostly fine apart from Parentaccountid on the CRM Account, which is not available to be selected due to having a TableRelation.  
 
  field(52; ParentAccountId; Guid)
        {
            Caption = 'Parent Account';
            Description = 'Choose the parent account associated with this account to show parent and child businesses in reporting and analytics.';
            ExternalName = 'parentaccountid';
            ExternalType = 'Lookup';
            TableRelation = "CRM Account".AccountId;
        }
 
Based on the articles online, I tend to see a suggestion to do something like 
 
[EventSubscriber(ObjectType::Codeunit, Codeunit::"CDS Setup Defaults", 'OnAfterResetCustomerAccountMapping', '', true, true)]
    local procedure HandleOnAfterResetCustomerAccountMapping(IntegrationTableMappingName: Code[20])
    var
        CRMAccount: Record "CRM Account";
        Customer: Record Customer;
        IntegrationFieldMapping: Record "Integration Field Mapping";
    begin
        //CDSAccountID for Customer
        InsertIntegrationFieldMapping(
        IntegrationTableMappingName,
          Customer.FieldNo("AUK AccountId"),
          CRMAccount.FieldNo(ParentAccountId),
          IntegrationFieldMapping.Direction::FromIntegrationTable,
          '', true, false);
    end;
 
    local 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;
 
The problem here is that 'OnAfterResetCustomerAccountMapping' is called at the end of a standard OnPrem function, so it obviously won't run 

    [Scope('OnPrem')]
    procedure ResetCustomerAccountMapping(IntegrationTableMappingName: Code[20]; IsTeamOwnershipModel: Boolean; ShouldRecreateJobQueueEntry: Boolean)
    var
 
Does anybody know a way that I can force the ParentAccountID field to be selectable for mapping?  
I have the same question (0)
  • Suggested answer
    OussamaSabbouh Profile Picture
    11,024 Super User 2026 Season 1 on at
    Hello,
     
    In Business Central SaaS, you can’t make ParentAccountId selectable in the Integration Field Mapping UI — lookup/TableRelation fields like this are intentionally filtered out, and the common event-based approach won’t work because ResetCustomerAccountMapping is OnPrem-only. The supported SaaS pattern is to insert the Integration Field Mapping record programmatically (for example from an Install or Upgrade codeunit), which bypasses the UI limitation entirely. Keep in mind that parentaccountid gives you a Dataverse Account GUID, so in practice you’ll also need custom logic to resolve that GUID to the coupled Customer if you want a real parent–child relationship in BC, not just a stored GUID.
     
    Regards,
    Oussama Sabbouh
  • GM-15011634-0 Profile Picture
    24 on at
    Thanks for your reply Oussama.  I have code in place that utilizes the GUID to find the data I need, and that all works.  My code  runs as long as the CRM Account has been queued.  If only that ParentAccountId on the Crm account has been changed, the record does not get queued.  
    You write "The supported SaaS pattern is to insert the Integration Field Mapping record programmatically (for example from an Install or Upgrade codeunit), which bypasses the UI limitation entirely"

    That is the part I am trying to do but cannot find the correct events to use or where to enter the code.  

    [EventSubscriber(ObjectType::Codeunit, Codeunit::"Integration Rec. Synch. Invoke", 'OnAfterModifyRecord', '', false, false)]
        local procedure "Integration Rec. Synch. Invoke_OnAfterModifyRecord"(IntegrationTableMapping: Record "Integration Table Mapping"; var SourceRecordRef: RecordRef; var DestinationRecordRef: RecordRef)
        var
            CRMAccount: Record "CRM Account";
            Customer: Record Customer;
            ParentCRM: Record "CRM Account";
        begin
            UpdateBillToCustomerNo(IntegrationTableMapping, SourceRecordRef, DestinationRecordRef);
        end;
     
    local procedure UpdateBillToCustomerNo(IntegrationTableMapping: Record "Integration Table Mapping"; var SourceRecordRef: RecordRef; var DestinationRecordRef: RecordRef)
        var
            CRMAccount: Record "CRM Account";
            Customer: Record Customer;
            ParentCRM: Record "CRM Account";
            EmptyGuid: Guid;
        begin
            // Only handle CRM Account → Customer mapping
            if GetSourceDestCode(SourceRecordRef, DestinationRecordRef) <> 'CRM Account-Customer' then
                exit;
            // Convert RecordRefs to actual records
            SourceRecordRef.SetTable(CRMAccount);
            DestinationRecordRef.SetTable(Customer);
            if CrmAccount.ParentAccountId = EmptyGuid then begin
                Customer."Bill-to Customer No." := '';
                Customer.Modify(false);
                DestinationRecordRef.GetTable(Customer);
                exit;
            end;
            if (CRMAccount."AUK Group Statement") and not (CRMAccount."Auk Broker Head Office") then begin
                if ParentCRM.Get(CRMAccount.ParentAccountId) then begin
                    if ParentCRM."AUK Agency Reference" <> Customer."Bill-to Customer No." then begin
                        Customer."Bill-to Customer No." := ParentCRM."AUK Agency Reference";
                        Customer.Modify(false);
                        // Push updated record back into the RecordRef
                        DestinationRecordRef.GetTable(Customer);
                    end;
            end 
        end;
  • Suggested answer
    Jeffrey Bulanadi Profile Picture
    9,106 Super User 2026 Season 1 on at
    Hi,

    In BC Online (SaaS) you cannot make the CRM ParentAccountId (lookup field) appear as a selectable mapping in the standard Dataverse/CRM integration mapping UI because it’s a GUID with a TableRelation. That lookup field isn’t exposed by default in the field list for integration mappings, and the standard setup doesn’t provide a way to change that selection through the UI or event mappings in SaaS.

    Here’s why:

    • The integration system uses integration tables and field mappings to synchronize data between Dataverse/CRM and BC. It only lists fields that are directly available for mapping and supported in that metadata schema. GUID lookup fields like parentaccountid with TableRelation are typically excluded. 
    • The events you mentioned (like OnAfterResetCustomerAccountMapping) are part of older or on-prem custom integration patterns but aren’t usable in SaaS because the core setup object for mappings is CDS/Dataverse Setup Defaults (Codeunit 7204) and it does not expose those CRM-specific reset events in the SaaS metadata. 
       

    What you can do instead (common workaround):

    • Add a custom field in BC to store the CRM ParentAccountId GUID.
    • Map that new field into the integration (either manually via the Integration Field Mappings page in BC, if the field becomes available, or by customizing table mappings via an extension that leverages the integration mapping APIs). (Microsoft Learn)
    • After syncing, use your own logic (AL code or Power Automate/Power Platform flows) to resolve the parent GUID to the correct Customer/Account relationship in BC.
       

    Helpful References
    Customizing option mappings with Microsoft Dataverse - Business Central | Microsoft Learn
    Codeunit "CDS Setup Defaults" | Microsoft Learn
    Mapping the tables and fields to synchronise - Business Central | Microsoft Learn

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

    Cheers
    Jeffrey

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,091 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,032 Super User 2026 Season 1

#3
Dhiren Nagar Profile Picture

Dhiren Nagar 946 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans