ALAppExtensions icon indicating copy to clipboard operation
ALAppExtensions copied to clipboard

[EventRequest] Codeunit 7205 CDS Int. Table. Subscriber - procedure FixPrimaryContactNo()

Open jlorenc01 opened this issue 3 years ago • 1 comments

Hi there,

in the mentioned codeunit 7205 the UpdateChildContactsParentCompany() procedure is called during CRM Account-Customer (Vendor) synchronization in the procedure HandleOnAfterInsertRecord(). The procedure UpdateChildContactsParentCompany() contains a call of the procedure FixPrimaryContactNo(). So the primary contact is set. And this is the difference when working in the BC GUI, where the primary contact can remain empty.

So we need the ability to have the primary contact empty after the synchronization from CRM as well. Below are some possible options, enough would be to have a possibility to clear the Primary Contact No.

local procedure UpdateChildContactsParentCompany(CRMAccountRecordRef: RecordRef)
var
    CRMIntegrationRecord: Record "CRM Integration Record";
    SkipFixPrimaryContactNo: Boolean;
    ...
begin
    ...
    if CRMContact.FindSet() then
        repeat
            if CRMIntegrationRecord.FindByCRMID(CRMContact.ContactId) then begin
                CRMContactRecordRef.GetTable(CRMContact);
                ContactRecordRef.Open(Database::Contact);
                if ContactRecordRef.GetBySystemId(CRMIntegrationRecord."Integration ID") then begin
	            OnUpdateChildContactsParentCompanyOnBeforeFixPrimaryContactNo(CRMContactRecordRef, ContactRecordRef, SkipFixPrimaryContactNo);
		    if not SkipFixPrimaryContactNo then
                        FixPrimaryContactNo(CRMContactRecordRef, ContactRecordRef);
                    UpdateContactParentCompany(CRMAccount.AccountId, ContactRecordRef);
                end;
                ContactRecordRef.Close();
            end;
        until CRMContact.Next() = 0;
end;

[IntegrationEvent(false, false)]
local procedure OnUpdateChildContactsParentCompanyOnBeforeFixPrimaryContactNo(CRMAccountRecordRef: RecordRef; CRMContactRecordRef: RecordRef; ContactRecordRef: RecordRef; var SkipFixPrimaryContactNo: Boolean)
begin
end;
local procedure FixPrimaryContactNo(SourceRecordRef: RecordRef; DestinationRecordRef: RecordRef)
var
   ...
begin
   ...
OnAfterFixPrimaryContactNo(SourceRecordRef, DestinationRecordRef)
end;

[IntegrationEvent(false, false)]
local procedure OnAfterFixPrimaryContactNo(SourceRecordRef: RecordRef; DestinationRecordRef: RecordRef)
begin
end;

jlorenc01 avatar Feb 12 '23 11:02 jlorenc01

Thanks for reporting this. We agree, and we’ll publish a fix asap, either in an update for the current version or in the next major release. Please do not reply to this, as we do not monitor closed issues. If you have follow-up questions or requests, please create a new issue where you reference this one.

Build ID: 53452.

JesperSchulz avatar Feb 21 '23 10:02 JesperSchulz