[Event Request] Codeunit 80 "Sales-Post" - Function "PostItemChargePerShpt" - OnBeforeDistributeChargeCalculation
Due to Service Value Credit Memos we need to have a different source where to get the information of "Quantity (Base)" from and when DistributeCharge is calculated. After all checks and calculations we have another call in the "If DistributeCharge then" for the service value credit memos. Therefore we need a possibility to exit the function with IsHandled (not just the Job No TESTFIELD) after "OnPostItemChargePerShptOnBeforeTestJobNo(SalesShptLine, IsHandled, SalesLine); if not IsHandled then SalesShptLine.TestField("Job No.", '');"
and proceed the function with its specialties in the event subscriber. Event should look like this:
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnBeforeDistributeChargeCalculation', '', true, true)]
local procedure "Sales-Post_OnBeforeDistributeChargeCalculation"
(
SalesShipmentLine: Record "Sales Shipment Line";
TempItemChargeAssgntSales: Record "Item Charge Assignment Sales";
DistributeCharge; Boolean;
IsHandled: Boolean;
QTYBase: Decimal;
).
Please always put the full detailed signature of the requested events. You help us implementing the requests faster when your request contains AL code copied from VSCode instead of screenshots. e.g. https://github.com/microsoft/ALAppExtensions/issues/10147
The signature is (as text) available in the original comment, completely with all wanted parameters? What are you missing?
Preferred placement in the code: local procedure PostItemChargePerShpt(SalesHeader: Record "Sales Header"; var SalesLine: Record "Sales Line") var SalesShptLine: Record "Sales Shipment Line"; TempItemLedgEntry: Record "Item Ledger Entry" temporary; ItemTrackingMgt: Codeunit "Item Tracking Management"; DistributeCharge: Boolean; IsHandled: Boolean; begin if not SalesShptLine.Get( TempItemChargeAssgntSales."Applies-to Doc. No.", TempItemChargeAssgntSales."Applies-to Doc. Line No.") then Error(ShipmentLinesDeletedErr);
IsHandled := false;
OnPostItemChargePerShptOnBeforeTestJobNo(SalesShptLine, IsHandled, SalesLine);
if not IsHandled then
SalesShptLine.TestField("Job No.", '');
### OnBeforeDistributeChargeCalculation
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. We will update this issue with information about availability. 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.
I just saw, that I missed two needed parameters, please deliver them as well :). Thanks in advance and sorry not forgetting them.
Here's the updated signature:
[EventSubscriber(ObjectType::Codeunit, Codeunit::"Sales-Post", 'OnBeforeDistributeChargeCalculation', '', true, true)] local procedure "Sales-Post_OnBeforeDistributeChargeCalculation" ( SalesShipmentLine: Record "Sales Shipment Line"; SalesHeader: Record "Sales Header"; SalesLine: Record "Sales Line"; TempItemChargeAssgntSales: Record "Item Charge Assignment Sales"; DistributeCharge; Boolean; IsHandled: Boolean; QTYBase: Decimal; )
This is the closed request. It will not be handled. Please create a new one and add a link to the original one.