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.
[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?