Skip to content

[US][Report][10135][Item Sales Statistics] Add integration event OnBeforePrintOnlyIfSalesCheck in the Item OnAfterGetRecord trigger, before the PrintOnlyIfSales skip check #30377

Description

@mavohra

Why do you need this change?

Our extension computes an alternate-unit-of-measure sales figure from our own Item Ledger Entry sum, which is expected to disagree with the standard FlowField-sourced Sales (Qty.) , that disagreement is the entire point of the customization. The standard OnAfterGetRecord trigger calculates Sales (Qty. ) via CalcFields and immediately decides, in the same statement block, whether to CurrReport.Skip() the record based on PrintOnlyIfSales and that FlowField value before any extension trigger (modify(Item) { trigger OnAfterAfterGetRecord }) ever runs. PrintOnlyIfSales itself is a private global with no accessible getter and it cannot be read from any kind of extension trigger, including a request-page control extension's OnAfterValidate.

Net effect: when "Only Items with Sales" is checked, an item, our own calculation shows as having real (alternate-UOM) sales can be silently skipped before our code runs, and an item we'd consider zero-sales can still print. We currently ship a second, custom checkbox that only produces a correct result when the standard "Only Items with Sales" is left unchecked which is a workaroud. A single event exposing the already-computed skip decision, raised after CalcFields and before CurrReport.Skip() , would let us fold our own figures into the one decision the user sees.

Describe the request

Add an integration event immediately after the existing CalcFields call and before the existing skip check, exposing the record and the already-computed skip boolean by var so a subscriber can override it in either direction:

trigger OnAfterGetRecord()
begin
    NoShow := false;
    if BreakdownByVariant then begin
        NoVariant := Text002;
        if AnyVariants() then
            NoShow := true;
    end;

    SetRange("Variant Filter");
    CalcFields("Sales (Qty.)", "Sales (LCY)", "COGS (LCY)");
    SkipRecord := ("Sales (Qty.)" = 0) and PrintOnlyIfSales;
    OnAfterGetRecordOnBeforePrintOnlyIfSalesCheck(Rec, PrintOnlyIfSales, SkipRecord);
    if SkipRecord then
        CurrReport.Skip();
    Profit := "Sales (LCY)" - "COGS (LCY)";
    ...
end;

Event Signature:

[IntegrationEvent(false, false)]
local procedure OnAfterGetRecordOnBeforePrintOnlyIfSalesCheck(var Item: Record Item; PrintOnlyIfSales: Boolean; var SkipRecord: Boolean)
begin
end;

Alternatives evaluated:

  • Reading PrintOnlyIfSales from a request-page control extension's OnAfterValidate , confirmed by the compiler that the variable is inaccessible from every kind of extension trigger, not just dataset ones.
  • Recomputing the entire skip/Profit/ItemProfitPct block ourselves inside a modify(Item) { trigger OnBeforeAfterGetRecord }, not viable even with access, because that trigger runs before the base's own CalcFields, so "Sales (Qty.)" isn't populated yet at that point.
    Internal work item: AB#644155

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM areaevent-requestRequest for adding an eventext-ready-to-implementReviewed and ready to implement and create PR

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions