Event Hooks
On this page, you will find information for implementing Event Publishers to Collection Management.
If the need for other event points emerge, send us a request for new ones by creating a ticket in our support system.
Codeunit 6052749 - CCM Epay Subscription Mgt.
Xmlport 6052636 - CCM Import Coll. Mgt. Setup
Codeunit 6052645 - CCM Advice Management
Codeunit 6052637 - CCM Journal Management
Report 6052638 - CCM Suggest Collections
Bemærk
Please note that the event hook descriptions below follow an older format. We are in the process of updating all event hooks to align with a new structure that enhances clarity and consistency.
Example of how to utilize the event
[EventSubscriber(Codeunit,6052692,OnBeforeWriteAddressToNode)]
LOCAL PROCEDURE OnBeforeWriteAddressToNodeTest(Customer : Record 18;CollJnlLine : Record 81;VAR VarName : Text;VAR VarName2 : Text;VAR VarAddress : Text;VAR VarAddress2 : Text;VAR VarPostCode : Code[20];VAR VarCountryCode : Code[10];VAR VarContact : Text;VAR VarPostAndCity : Text);
BEGIN
IF Customer."No." = '10000' THEN BEGIN
VarName := 'Test Name';
VarName2 := 'Test Name 2';
VarAddress := 'Test Address';
VarAddress2 := 'Test Address 2';
VarPostCode := '1234';
VarCountryCode := 'DK';
VarContact := 'Test Contact';
VarPostAndCity := '1234 Test City';
END;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052770, OnBeforeSetFilterOnCollAgreeJnlBatch)]
local procedure OnBeforeSetFilterOnCollAgreeJnlBatch (var CollAgreeJnlBatch: Record CCM Coll. Agreement Jnl. Batch);
Var
Setup: Record “Setup”;
begin
Setup.Get();
CollAgreeJnlBatch.SetRange(“Journal Batch Name”, Setup.”Defined Export Jnl Batch Name”);
end;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052770, OnBeforeRunSuggAgreeForTransfer)]
local procedure OnBeforeRunSuggAgreeForTransfer (var SuggAgreeForTransfer: Report "CCM Sugg. Agree. for Trans");
Var
CCMCollectionAgreement: Record “CCM Collection Agreement”;
Begin
CCMCollectionAgreement.Get(CustomerNo, CustomerGroup,PaymentMethodCode,CollMethod);
SuggAgreeForTransfer.SetTableView(CCMCollectionAgreement);
end;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052639,OnValidateAgreementAfterCustomerGet)]
LOCAL PROCEDURE TestOnValidateAgreementAfterCustomerGet(VAR Customer : Record 18);
BEGIN
IF Customer."No." = '10000' THEN
Customer."VAT Registration No." := '0101000001'; // Insert a social security number - dont Customer.MODIFY
// Can be used with events:
// Codeunit 6052692 CreateNewAgreementSetCustVatRegNo
// Codeunit 6052692 ExportCollectionsSetDebtorCVROrCPRNr
// Codeunit 6052639 OnValidateCollGenerelAfterCustomerGet
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052639,OnValidateCollGenerelAfterCustomerGet)]
LOCAL PROCEDURE TestOnValidateCollGenerelAfterCustomerGet(VAR Customer : Record 18);
BEGIN
IF Customer."No." = '10000' THEN
Customer."VAT Registration No." := '0101000001'; // Insert a social security number - dont Customer.MODIFY
// Can be used with events:
// Codeunit 6052692 CreateNewAgreementSetCustVatRegNo
// Codeunit 6052692 ExportCollectionsSetDebtorCVROrCPRNr
// Codeunit 6052639 OnValidateAgreementAfterCustomerGet
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052639,OnValidateCollGenerelAfterCustomerGet)]
LOCAL PROCEDURE TestOnValidateCollGenerelAfterCustomerGet(VAR Customer : Record 18);
BEGIN
IF Customer."No." = '10000' THEN
Customer."VAT Registration No." := '0101000001'; // Insert a social security number - dont Customer.MODIFY
// Can be used with events:
// Codeunit 6052692 CreateNewAgreementSetCustVatRegNo
// Codeunit 6052692 ExportCollectionsSetDebtorCVROrCPRNr
// Codeunit 6052639 OnValidateAgreementAfterCustomerGet
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052645,OnBeforeCreatePDFAttachments)]
LOCAL PROCEDURE TestOnBeforeCreatePDFAttachments@1(VAR CustLE : Record 21;VAR TempFile : Record 6052664;VAR SkipPDFCreation : Boolean);
VAR
MyOutStream : OutStream;
BEGIN
SkipPDFCreation := TRUE;
IF CustLE.FINDSET THEN
REPEAT
TempFile.CreateEmpty('AFilename.PDF');
TempFile.Data.CREATEOUTSTREAM(MyOutStream);
// Use the MyOutStream to add your PDF to the TempFile...
TempFile.INSERT(TRUE);
UNTIL CustLE.NEXT = 0;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052738,OnAfterSalesPostPreCollJournalCheck)]
LOCAL PROCEDURE TestOnAfterSalesPostPreCollJournalCheck(VAR CollSystem : Record 6052637;VAR CustLE : Record 21);
BEGIN
IF CustLE.FINDFIRST THEN
IF CustLE."Customer No." = '10000' THEN
CollSystem."Journal Batch Name" := 'BatchA';
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052648,OnBeforeUnApplyCustLedgEntry)]
LOCAL PROCEDURE OnBeforeUnApplyCustLedgEntry(CollImpJnlLine : Record 6052667;VAR ClosedByEntryNo : Integer);
VAR
CollEntry : Record 6052647;
BEGIN
IF CollImpJnlLine."Coll. Ledg. Entry No." <> 0 THEN BEGIN
CollEntry.GET(CollImpJnlLine."Coll. Ledg. Entry No.")
// With CollEntry you can find the info needed...
// If needed you can set the ColsedByEntryNo
END;
END;
Example of how to utilize the event
[EventSubscriber(Report,6052638,OnFindCollectionAgreementRem,"",Skip)]
LOCAL PROCEDURE OnFindCollectionAgreementSuggestCollRem@12(VAR CollJnlLine@1000 : Record 81;VAR CollAgreement@1001 : Record 6052640;VAR IsHandled@1002 : Boolean);
BEGIN
// Creating collections based on Reminders
// Get Agreement in a special way if needed...
CollAgreement.GET(CollJnlLine."Account No.",CollJnlLine."CCM Customer Group",CollJnlLine."Payment Method Code",CollJnlLine."CCM Collection Method");
IsHandled := TRUE;
END;
Example of how to utilize the event
[EventSubscriber(Report,6052638,OnFindCollectionAgreement,"",Skip)]
LOCAL PROCEDURE OnFindCollectionAgreementSuggestColl@10(VAR CustLedgEntry@1000 : Record 21;VAR CollAgreement@1001 : Record 6052640;VAR IsHandled@1002 : Boolean);
BEGIN
// Creating collections based on Customer Ledger Entries
// Get Agreement in a special way if needed...
CollAgreement.GET(CustLedgEntry."Customer No.",CustLedgEntry."CCM Customer Group",CustLedgEntry."Payment Method Code",CustLedgEntry."CCM Collection Method");
IsHandled := TRUE;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052639,OnFindCollectionAgreement,"",Skip)]
LOCAL PROCEDURE OnFindCollectionAgreementValidate@11(VAR CollJnlLine@1000 : Record 81;VAR CollAgreement@1001 : Record 6052640;VAR IsHandled@1002 : Boolean);
BEGIN
// Works on Normal and Stop collections.
// Get Agreement in a special way if needed...
CollAgreement.GET(CollJnlLine."Account No.",CollJnlLine."CCM Customer Group",CollJnlLine."Payment Method Code",CollJnlLine."CCM Collection Method");
IsHandled := TRUE;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052692,OnFindCollectionAgreement,"",Skip)]
LOCAL PROCEDURE OnFindCollectionAgreement@9(VAR CollJnlLine@1000 : Record 81;VAR CollAgreement@1001 : Record 6052640;VAR IsHandled@1002 : Boolean);
BEGIN
// Works on Normal and Stop collections.
// Get Agreement in a special way if needed...
CollAgreement.GET(CollJnlLine."Account No.",CollJnlLine."CCM Customer Group",CollJnlLine."Payment Method Code",CollJnlLine."CCM Collection Method");
IsHandled := TRUE;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052639,OnBeforeValidateBeforePost,"",Skip)]
LOCAL PROCEDURE OnBeforeValidateBeforePostTest@7(VAR SalesHeader@1000 : Record 36;VAR ServHeader@1001 : Record 5900;VAR IsHandled@1002 : Boolean);
BEGIN
// Add your own before post validation here...
IsHandled := FALSE;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052731,OnBeforeDefaultAgreementMessage,"",Skip)]
LOCAL PROCEDURE OnBeforeDefaultAgreementMessageSalesHeaderTest@6(VAR SalesHeader@1000 : Record 36;VAR IsHandled@1001 : Boolean);
BEGIN
// No Message :)
SalesHeader."CCM Customer Group" := '';
SalesHeader."CCM Collection Method" := '';
IsHandled := TRUE;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052735,OnBeforeDefaultAgreementMessage,"",Skip)]
LOCAL PROCEDURE OnBeforeDefaultAgreementMessageTest@4(VAR GenJournalLine@1000 : Record 81;VAR IsHandled@1001 : Boolean);
BEGIN
// No Message :)
GenJournalLine."CCM Customer Group" := '';
GenJournalLine."CCM Collection Method" := '';
IsHandled := TRUE;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052637,OnBeforeCreateCollJnlAdviceHeaderInfo)]
LOCAL PROCEDURE OnBeforeCreateCollJnlAdviceHeaderInfoTest@3(GlobalCollAdviceDef@1000 : Record 6052642;CollJnlLine@1001 : Record 81;CustLedgEntry@1002 : Record 21;NoOfAdvChar@1003 : Integer;VAR AdvLineNo@1004 : Integer;CollEntryNo@1005 : Integer);
VAR
CollEntryAdvice@1006 : Record 6052648;
BEGIN
CollEntryAdvice."Coll. Entry No." := CollEntryNo;
AdvLineNo += 10000;
CollEntryAdvice."Line No." := AdvLineNo;
CollEntryAdvice.Type := CollEntryAdvice.Type::Normal;
CollEntryAdvice."Advice Description" := 'Some extra info';
CollEntryAdvice.INSERT;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052637,OnAfterCreateCollJnlAdviceHeaderInfo)]
LOCAL PROCEDURE HeaderInfoTest@1(CollJnlLine@1000 : Record 81;CustLedgEntry@1001 : Record 21;NoOfAdvChar@1002 : Integer;VAR AdvLineNo@1003 : Integer;CollEntryNo@1004 : Integer);
VAR
CollEntryAdvice@1005 : Record 6052648;
BEGIN
CollEntryAdvice."Coll. Entry No." := CollEntryNo;
AdvLineNo += 10000;
CollEntryAdvice."Line No." := AdvLineNo;
CollEntryAdvice.Type := CollEntryAdvice.Type::Normal;
CollEntryAdvice.Bold := TRUE;
CollEntryAdvice."Advice Description" := CustLedgEntry.Description;
CollEntryAdvice.INSERT;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052637,OnAfterCreateAdviceDocPrCollection)]
LOCAL PROCEDURE OnAfterCreateAdviceDocPrCollectionTest@1(GlobalCollAdviceDef@1000 : Record 6052642;CollJnlLine@1001 : Record 81;CustLedgEntry@1002 : Record 21;AmountExclVAT@1003 : Decimal;VATAmount@1004 : Decimal;AmountInclVAT@1005 : Decimal;NoOfAdvChar@1006 : Integer;VAR AdvLineNo@1007 : Integer;CollEntryNo@1008 : Integer);
VAR
CollEntryAdvice@1009 : Record 6052648;
BEGIN
CollEntryAdvice."Coll. Entry No." := CollEntryNo;
AdvLineNo += 10000;
CollEntryAdvice."Line No." := AdvLineNo;
CollEntryAdvice.Type := CollEntryAdvice.Type::Normal;
CollEntryAdvice."Advice Description" := CustLedgEntry."Applies-to ID" + ' (' + FORMAT(AmountInclVAT) + ')';
CollEntryAdvice.INSERT;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052637,OnAfterCreateAdvicePrInvoice)]
LOCAL PROCEDURE OnAfterCreateAdvicePrInvoiceTest@8(GlobalCollAdviceDef@1000 : Record 6052642;CollJnlLine@1001 : Record 81;CustLedgEntry@1002 : Record 21;AmountExclVAT@1003 : Decimal;VATAmount@1004 : Decimal;AmountInclVAT@1005 : Decimal;NoOfAdvChar@1006 : Integer;VAR AdvLineNo@1007 : Integer;CollEntryNo@1008 : Integer);
VAR
CollEntryAdvice@1009 : Record 6052648;
BEGIN
CollEntryAdvice."Coll. Entry No." := CollEntryNo;
AdvLineNo += 10000;
CollEntryAdvice."Line No." := AdvLineNo;
CollEntryAdvice.Type := CollEntryAdvice.Type::Normal;
CollEntryAdvice."Advice Description" := 'Amount Incl. VAT: ' + FORMAT(AmountInclVAT);
CollEntryAdvice.INSERT;
END;
Example of how to utilize the events
[EventSubscriber(Codeunit,6052637,OnCreateAdvice)]
LOCAL PROCEDURE AdviceTest@1160040000(CollJnlLine@1160040000 : Record 81;CollEntryNo@1160040001 : Integer;VAR AdvLineNo@1160040002 : Integer);
VAR
CollEntryAdvice@1160040004 : Record 6052648;
BEGIN
IF CollJnlLine."Account No." = '10000' THEN BEGIN
CollEntryAdvice.INIT;
CollEntryAdvice."Coll. Entry No." := CollEntryNo;
AdvLineNo += 10000;
CollEntryAdvice."Line No." := AdvLineNo;
CollEntryAdvice."Advice Description" := 'Test advisering';
CollEntryAdvice.INSERT;
AdvLineNo += 10000;
CollEntryAdvice."Line No." := AdvLineNo;
CollEntryAdvice."Advice Description" := 'Test advisering - linje 2';
CollEntryAdvice.INSERT;
END;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052637,OnAfterCreateCollJnlAdviceDocNosOnly)]
LOCAL PROCEDURE DocNosOnlyTest@2(CollJnlLine@1000 : Record 81;NoOfAdvChar@1001 : Integer;VAR AdvLineNo@1002 : Integer;CollEntryNo@1003 : Integer);
VAR
CollEntryAdvice@1005 : Record 6052648;
CustLedgEntry@1004 : Record 21;
DescriptionText@1006 : Text;
BEGIN
//NB!
// IF CollJnlLine."Applies-to ID" <> '' THEN multiple Customer Ledger Entries is collected to one Collection Journal Line.
// Use CollJnlLine."Applies-to ID" to find all Customer Ledger Entries if needed.
// Find Customer Ledger Entries if needed...
IF CollJnlLine."Applies-to ID" <> '' THEN BEGIN
CustLedgEntry.SETCURRENTKEY("Customer No.","Applies-to ID",Open,Positive,"Due Date");
CustLedgEntry.SETRANGE("Customer No.",CollJnlLine."Account No.");
CustLedgEntry.SETRANGE(Open,TRUE);
CustLedgEntry.SETRANGE("Applies-to ID",CollJnlLine."Applies-to ID");
IF CustLedgEntry.FINDSET THEN
REPEAT
DescriptionText += CustLedgEntry.Description + ', ';
UNTIL CustLedgEntry.NEXT = 0;
END ELSE BEGIN
IF CollJnlLine."CCM Cust. Ledger Entry No." <> 0 THEN
CustLedgEntry.GET(CollJnlLine."CCM Cust. Ledger Entry No.");
DescriptionText := CustLedgEntry.Description;
END;
CollEntryAdvice."Coll. Entry No." := CollEntryNo;
AdvLineNo += 10000;
CollEntryAdvice."Line No." := AdvLineNo;
CollEntryAdvice.Type := CollEntryAdvice.Type::Normal;
CollEntryAdvice.Bold := TRUE;
CollEntryAdvice."Advice Description" := DescriptionText;
CollEntryAdvice.INSERT;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052637,OnBeforeCollJnlUpdateStatus)]
LOCAL PROCEDURE OnBeforeCollJnlUpdateStatus@7(VAR CollJnlLine@1000 : Record 81;VAR ExitUpdateStatus@1001 : Boolean);
BEGIN
// Demosystem code:
ExitUpdateStatus := TRUE; // Will stop the Import Status function.
CollJnlLine."CCM Status" := CollJnlLine."CCM Status"::Processing;
CollJnlLine.MODIFY;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052637,OnCreateBalEntry)]
LOCAL PROCEDURE OnCreateBalEntryTest@1160040000(VAR CollJnlLine@1000 : Record 81);
BEGIN
CollJnlLine.Description = 'Ny modpost beskrivelse - test’;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052637,OnCollectCollJnlLines)]
LOCAL PROCEDURE OnCollectLineTest@1160040000(VAR CollJnlLine@1000 : Record 81);
BEGIN
CollJnlLine.Description = 'Samlede opkrævninger - test’;
END;
Example of how to utilize the event
[EventSubscriber(Report,6052638,OnBeforeInsertCollJnlLine)]
LOCAL PROCEDURE test@1160040001(VAR NewCollJnlLine@1160040000 : Record 81;CustLedgEntry@1160040001 : Record 21);
BEGIN
IF CustLedgEntry."Customer No." = '10000' THEN
NewCollJnlLine.Description := 'Test tekst';
END;
Example of how to utilize the event
[EventSubscriber(Report,6052638,OnBeforeInsertCollJnlLineReminder)]
LOCAL PROCEDURE test2@1160040004(VAR NewCollJnlLine@1160040000 : Record 81;IssRemHeader@1160040001 : Record 297);
BEGIN
IF IssRemHeader."Customer No." = '10000' THEN
NewCollJnlLine.Description := 'Test rykker tekst';
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052645,OnBeforePrintToFile)]
LOCAL PROCEDURE test@1160040000(CustLE@1160040000 : Record 21;VAR ReportID@1160040001 : Integer)
BEGIN
CASE CustLE."Document Type" OF
CustLE."Document Type"::Invoice: ReportID := 206;
CustLE."Document Type"::"Credit Memo": ReportID := 207;
CustLE."Document Type"::Reminder: ReportID := 117;
END;
END;
Example of how to utilize the events
[EventSubscriber(Table,6052647,OnAfterInsertEntry)]
LOCAL PROCEDURE InsertEntryTest@1160040003(VAR CollEntry@1160040000 : Record 6052647;CollJnlLine@1160040001 : Record 81);
BEGIN
IF CollJnlLine."Account No." = '10000' THEN
CollEntry."E-Mail advice Sent" := TRUE;
END;
Example of how to utilize the events
[EventSubscriber(Table,6052647,OnAfterUpdateEntry)]
LOCAL PROCEDURE UpdateEntryTest@1160040005(VAR CollEntry@1160040000 : Record 6052647;CollJnlLine@1160040001 : Record 81);
BEGIN
IF CollJnlLine."Account No." = '10000' THEN
CollEntry."Recipient Email" := 'testmail@continia.dk';
END;
Example of how to utilize the events
[EventSubscriber(Codeunit,6052648,OnAfterCreateCashReceipt)]
LOCAL PROCEDURE AfterCashReceiptTest@1160040002(VAR GenJnlLine@1160040000 : Record 81;CollImportJnlLine@1160040001 : Record 6052667);
BEGIN
IF GenJnlLine."Account No." = '10000' THEN BEGIN
GenJnlLine.Comment := 'Test';
END;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052648,OnBeforeInsertRefundLinesInCollJnl)]
LOCAL PROCEDURE BeforeReminderInsertTest@1160040002(VAR GenJnlLine@1160040000 : Record 81;CollImportJnlLine@1160040001 : Record 6052667);
BEGIN
GenJnlLine.Description = 'LS-tilbageført betaling’;
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052692,ExportCollectionsSetDebtorCVROrCPRNr)]
LOCAL PROCEDURE TestExportCollectionsSetDebtorCVROrCPRNr@8(Customer@1000 : Record 18;VAR CVROrCPR@1001 : Text);
BEGIN
IF Customer."No." = '10000' THEN
CVROrCPR := '0101000001';
// Can be used with events:
// Codeunit 6052692 CreateNewAgreementSetCustVatRegNo
// Codeunit 6052639 OnValidateAgreementAfterCustomerGet
// Codeunit 6052639 OnValidateCollGenerelAfterCustomerGet
END;<
Example of how to utilize the event
[EventSubscriber(Codeunit,6052692,ExportCollectionsSetCustValues,"",Skip,Skip)]
LOCAL PROCEDURE Test2@3(VAR Customer@1000 : Record 18);
BEGIN
Customer."VAT Registration No." := CPRFunctions.GetCustCPRNo(Customer."No.");
Customer.Name += ' Test';
END;
Example of how to utilize the event
[EventSubscriber(Codeunit,6052692,CreateNewAgreementSetCustVatRegNo)]
LOCAL PROCEDURE TestCreateNewAgreementSetCustVatRegNo@12(VAR Customer@1000 : Record 18);
BEGIN
IF Customer."No." = '10000' THEN
Customer."VAT Registration No." := '0101000001'; // Insert a social security number - dont Customer.MODIFY
// Can be used with events:
// Codeunit 6052639 OnValidateAgreementAfterCustomerGet
// Codeunit 6052639 OnValidateCollGenerelAfterCustomerGet
// Codeunit 6052692 ExportCollectionsSetDebtorCVROrCPRNr
END;
Example of how to utilize the events
[EventSubscriber(Codeunit,6052692,ExportAgreementsCreateOnBeforeModifyAgree)]
LOCAL PROCEDURE ExportAgreementTest@1160040006(VAR CollAgree@1160040000 : Record 6052640;AgreeJnlLine@1160040001 : Record 6052654);
BEGIN
IF CollAgree."Customer No." = '10000' THEN
CollAgree.Description := 'Agreement export test'
END;
Example of how to utilize the events
[EventSubscriber(Codeunit,6052692,ExportCollectionsSetDebtorCustomerNr)]
LOCAL PROCEDURE SetDebtorCustomerNrTest@1160040007(CollJnlLine@1160040000 : Record 81;VAR DebtorCustomerNr@1160040001 : Code[30]);
BEGIN
DebtorCustomerNr := CollJnlLine."Contract No.";
END;
Example of how to utilize the events
[EventSubscriber(Codeunit,6052692,ExportCollectionsOnAfterModifyCollJnlLine)]
LOCAL PROCEDURE GetCollJnlLineAferExportCollectionTest@1160040008(VAR CollJnlLine@1160040000 : Record 81);
BEGIN
CollJnlLine.Description := 'Exported';
CollJnlLine.MODIFY;
END;