Skip to content

[W1][Report][99001048][Planning Availability] Add integration event OnAfterGetRecordPurchaseLineBeforeSelection in OnAfterGetRecord #30140

@mavohra

Description

@mavohra

Why do you need this change?

We need to conditionally skip the if SelectionReq then block inside OnAfterGetRecord on the "Purchase Line" dataitem based on lot status exclusion rules. Our customization fetches the Item record for the current purchase line and calls LotStatusMgmt.SetInboundExclusions to determine whether purchase receipts are excluded from planning for that item. If ExcludePurch is true, the entire scheduling block must be skipped.

The SetInboundExclusions function evaluates the lot status configuration for the item and returns exclusion flags per supply type purchase, sales return, and output. These flags are item-specific and can only be determined at runtime when the actual item record is available. The base app has no awareness of these exclusion flags and will unconditionally proceed into the scheduling block for every purchase line where SelectionReq is true, regardless of whether that item's lot status marks it as excluded from planning.

There is no event before the if SelectionReq then block that exposes the current "Purchase Line" record and allows a subscriber to suppress execution via an IsHandled guard. Without this event there is no clean extensibility point to intercept and conditionally bypass the base app scheduling logic from an extension.

Describe the request

Add an integration event OnAfterGetRecordPurchaseLineBeforeSelection in OnAfterGetRecord on the "Purchase Line" dataitem before the if SelectionReq then block

trigger OnAfterGetRecord()
                begin
                    ReqLine2.SetRange("Ref. Order No.", "Document No.");
                    ReqLine2.SetRange("Ref. Line No.", "Line No.");
                    if ReqLine2.FindFirst() then
                        CurrReport.Skip();
                        IsHandled := false;
                        OnAfterGetRecordPurchaseLineBeforeSelection("Purchase Line", IsHandled); 
                    if not IsHandled then

                    if SelectionReq then begin
                        NewRecordWithDetails("Expected Receipt Date", "No.", Description);
                        TempPlanningBuffer."Document Type" := TempPlanningBuffer."Document Type"::"Purchase Order";
                        TempPlanningBuffer."Document No." := "Document No.";
                        TempPlanningBuffer."Scheduled Receipts" := "Outstanding Qty. (Base)";
                        TempPlanningBuffer.Insert();
                    end else begin
                        TempPlanningBuffer.SetRange("Item No.", "No.");
                        TempPlanningBuffer.SetRange(Date, "Expected Receipt Date");
                        if TempPlanningBuffer.Find('-') then begin
                            TempPlanningBuffer."Scheduled Receipts" := TempPlanningBuffer."Scheduled Receipts" + "Outstanding Qty. (Base)";
                            TempPlanningBuffer.Modify();
                        end else begin
                            NewRecordWithDetails("Expected Receipt Date", "No.", Description);
                            TempPlanningBuffer."Scheduled Receipts" := "Outstanding Qty. (Base)";
                            TempPlanningBuffer.Insert();
                        end;
                    end;
                end;

Event Signature:

[IntegrationEvent(false, false)]
local procedure OnAfterGetRecordPurchaseLineBeforeSelection(var PurchaseLine: Record "Purchase Line"; var IsHandled: Boolean)
begin
end;

Alternatives evaluated:
A report extension's OnAfterGetRecord runs in addition to the base app trigger, not instead of it, so there is no way to suppress the base app's if SelectionReq then block from an extension without an IsHandled guard. No event currently exists before the if SelectionReq then block in this trigger.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions