In #27592, a solution has been added to overrule the CalcNoOfReservedFromStockSalesOrders.
I think this request should be re-evaluated and adopt the same pattern on some other places too:
codeunit 1311 "Activities Mgt." - CalcNoOfReservedFromStockSalesOrders (covered by #27592)
codeunit 1311 "Activities Mgt." - DrillDownNoOfReservedFromStockSalesOrders - missing an OnBefore...publisher
table 9053 "Sales Cue"- CalcNoOfReservedFromStockSalesOrders - missing an OnBefore...publisher
table 9053 "Sales Cue"- DrillDownNoOfReservedFromStockSalesOrders - missing an OnBefore...publisher
However, it would be better if the code can be refactored to avoid code cloning and provide one single place where filters are placed on the SalesHeader, allowing us to use one single event publisher to include additional filters on the SalesHeader and exclude certain records. (e.g. those Completely Shipped,
Whether Sales Cue of Activities Mgt. is used, is up to MS.
Possible code suggestion:
#region CalcNoOfReservedFromStockSalesOrders
procedure CalcNoOfReservedFromStockSalesOrders() : Integer
var
[SecurityFiltering(SecurityFilter::Filtered)]
SalesHeader: Record "Sales Header";
begin
exit(CalcNoOfReservedFromStockSalesOrders(SalesHeader)); // Moved the SalesHeader filter logic to a separate function
end;
#endregion CalcNoOfReservedFromStockSalesOrders
#region DrillDownNoOfReservedFromStockSalesOrders
procedure DrillDownNoOfReservedFromStockSalesOrders()
var
[SecurityFiltering(SecurityFilter::Filtered)]
SalesHeader: Record "Sales Header";
begin
CalcNoOfReservedFromStockSalesOrders(SalesHeader); // Moved the SalesHeader filter logic to a separate function
SalesHeader.MarkedOnly(true);
Page.Run(Page::"Sales Order List", SalesHeader);
end;
#endregion DrillDownNoOfReservedFromStockSalesOrders
#region CalcNoOfReservedFromStockSalesOrders
local procedure CalcNoOfReservedFromStockSalesOrders(var SalesHeader: Record "Sales Header") Number: Integer
begin
SalesHeader.SetRange("Document Type", SalesHeader."Document Type"::Order);
SalesHeader.SetLoadFields("Document Type", "No.");
OnCalcNoOfReservedFromStockSalesOrders_OnBeforeSetFilters(SalesHeader); // Added publisher to allow custom filtering
if SalesHeader.FindSet() then
repeat
if SalesHeader.GetQtyReservedFromStockState() = Enum::"Reservation From Stock"::Full then begin
Number += 1;
SalesHeader.Mark(true);
end;
until SalesHeader.Next() = 0;
end;
#endregion CalcNoOfReservedFromStockSalesOrders
#region OnCalcNoOfReservedFromStockSalesOrders_OnBeforeSetFilters
[IntegrationEvent(false, false)]
local procedure OnCalcNoOfReservedFromStockSalesOrders_OnBeforeSetFilters(var SalesHeader: Record "Sales Header")
begin
// Supports adding filters on one place only, allowing the calculation and drilldown to be correct at all places (Sales Cue / Act. Mgt)
end;
#endregion OnCalcNoOfReservedFromStockSalesOrders_OnBeforeSetFilters
Describe the request
In #27592, a solution has been added to overrule the CalcNoOfReservedFromStockSalesOrders. I think this request should be re-evaluated and adopt the same pattern on some other places too:
However, it would be better if the code can be refactored to avoid code cloning and provide one single place where filters are placed on the SalesHeader, allowing us to use one single event publisher to include additional filters on the SalesHeader and exclude certain records. (e.g. those Completely Shipped,
Whether Sales Cue of Activities Mgt. is used, is up to MS.
Possible code suggestion:
Additional context
x Internal work item: AB#558152