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

Notifications

Announcements

Community site session details

Community site session details

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

Map ParentAccountId from CRM Account to Business Central

(0) ShareShare
ReportReport
Posted on by
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)

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

News and Announcements

Season of Giving Solutions is Here!

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 1,742

#2
YUN ZHU Profile Picture

YUN ZHU 844 Super User 2025 Season 2

#3
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 719 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans