AL icon indicating copy to clipboard operation
AL copied to clipboard

Codeunit 100, issue using new OnAfterCheckPostingGroups event.

Open DonHendriksen opened this issue 8 years ago • 6 comments

Recently there are several events delivered in CU 100. One of them is the OnAfterCheckPostingGroups event. Now I want to use this event from an external CU, but I ran into an issue.

Take a look at CU 100. We start with function CheckPostingGroups. Within this function there are a lot of Local functions called, and at last the function InsertGroup is called (many times). If we use the OnAfterCheckPostingGroups Event to process our company specific function(s) we need to get access to the InsertGroup function. So, solution could be a global function. But the InsertGroup function also uses Global variables. Variables we can't use or set from an external codeunit where the event is used.

What't the opinion from Microsoft about this? Can this be fixed?

Our Company specific function, with italic text: CLEAR(Key); GLAccWhereUsed."Table ID" := DATABASE::"Target Account Non-DAEB"; GLAccWhereUsed."Table Name" := TargetAccountNonDaeb.TABLECAPTION;

Company.SETFILTER(Name,'<>%1',COMPANYNAME); IF Company.FINDSET THEN REPEAT TargetAccountNonDaeb.CHANGECOMPANY(Company.Name); WITH TargetAccountNonDaeb DO BEGIN Key[1] := InCompMsg + Company.FIELDCAPTION(Name); Key[2] := FIELDCAPTION("Company Name"); Key[3] := FIELDCAPTION("G/L Account No."); SETRANGE("Company Name", COMPANYNAME); SETRANGE("Target Account Non-DAEB", GLAccNo); IF FIND('-') THEN REPEAT Key[4] := Company.Name; Key[5] := "Company Name"; Key[6] := "G/L Account No."; InsertGroup(GLAccNo,"Target Account Non-DAEB",FIELDCAPTION("Target Account Non-DAEB"),Key); UNTIL NEXT = 0; END; UNTIL Company.NEXT = 0;

DonHendriksen avatar Mar 14 '18 11:03 DonHendriksen

Hello! Can you use function InsertGroupForRecord if we make it External?

AlexanderYakunin avatar Mar 20 '18 15:03 AlexanderYakunin

Hi Alexander, can you be more specific. We can't find any Function named InsertGroupForRecord (checked in the latest build). So, I guess you want to create a new Function where we can pass the GLAccWhereUsed Table? Then still the NextEntryNo is an issue. In our case we just want to add 1 record in the GLAccWhereUsed table, so we can use the current code in the InsertGroup Function. But other companies maybe need to add more records and then the NextEntryNo code is usefull. Regards, Don

DonHendriksen avatar Mar 27 '18 08:03 DonHendriksen

We probably look into different versions of COD100. Let me attach latest version which I use. Please compare with what you have and let me know how you see next actions. I'm ready to add events if really needed. COD100.TXT

AlexanderYakunin avatar Mar 27 '18 08:03 AlexanderYakunin

Alexander, the version you attached is in my opinion a version which solves the issue. But in what release will this object be delivered? We checked the Dynamics 365 Build version 12.0.21229, and in this version the 'old' version is still available. We use NL version.

DonHendriksen avatar Mar 27 '18 09:03 DonHendriksen

This function have been added March 16 to our Main branch. I already asked my team to port it down to version 12.0, so it will be available for next update.

AlexanderYakunin avatar Mar 28 '18 10:03 AlexanderYakunin

Perfect Alexander. Then this issue is solved. I will close the ticket.

DonHendriksen avatar Mar 28 '18 10:03 DonHendriksen