Skip to content

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

Description

@mavohra

Why do you need this change?

Same rationale as the Item-level companion request #30377 , scoped to Breakdown-By-Variant mode: the Item Variant OnAfterGetRecord trigger has an identical CalcFields + PrintOnlyIfSales skip pattern on Item."Sales (Qty.)", hit whenever "Breakdown By Variant" is enabled on the request page. PrintOnlyIfSales is a private global with no accessible getter. It's unreachable from every kind of extension trigger.

Net effect: when "Only Items with Sales" and "Breakdown By Variant" are both checked, a variant our own alternate-UOM calculation shows as having real sales can be silently skipped before our extension trigger runs, and a variant we'd consider zero-sales can still print. 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, at the variant level as well as the item level.

Describe the request

 dataitem("Item Variant"; "Item Variant")
  {
                DataItemLink = "Item No." = field("No.");
                DataItemTableView = sorting("Item No.", Code);
                column(Item_Variant_Code; Code)
                {
                }
...

   trigger OnAfterGetRecord()
   begin
       if BlankVariant then begin
           Code := '';
           "Item No." := '';
           Description := 'Blank Variant';
           "Description 2" := '';
           BlankVariant := false;
       end;

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

...

}

Event Signature:

[IntegrationEvent(false, false)]
local procedure OnItemVariantOnAfterGetRecordOnBeforePrintOnlyIfSalesCheck(var Item: Record Item; ItemVariant: Record "Item Variant"; 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 Variant") { trigger OnBeforeAfterGetRecord }, not viable even with access, because that trigger runs before the base's own CalcFields, so Item."Sales (Qty.)" isn't populated yet at that point.
    Internal work item: AB#644154

Metadata

Metadata

Assignees

No one assigned

    Labels

    SCMGitHub request for SCM areaevent-requestRequest for adding an event

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions