Skip to content

[W1][Report][99001017][Calculate Plan - Plan. Wksh.] Add integration event OnAfterSetAtStartPositionOnPreDataItem in Item dataitem OnPreDataItem trigger after SetAtStartPosition := true #30118

@mavohra

Description

@mavohra

Why do you need this change?

We need to populate a MarkedItem record based on Supply Chain Group Code filter immediately after SetAtStartPosition := true in the Item dataitem OnPreDataItem trigger of Report 99001017 "Calculate Plan - Plan. Wksh.". The standard code does not provide a way to mark specific items for planning based on supply chain group membership at this point.

MarkedItem must be ready before OnAfterGetRecord starts iterating over items, because every item is checked against it to decide whether to skip planning or not. There is no way to populate it correctly after the data item starts iterating.

OnBeforeItemOnPreDataItem fires too early — before planning initialization is complete. OnAfterItemOnPreDataItem fires too late — after Commit() when iteration is already about to begin. No event exists between SetAtStartPosition := true and the ReqLine/PlanningErrorLog filter setup that exposes Item and MarkedItem.

Describe the request

Add an integration event OnAfterSetAtStartPositionOnPreDataItem in the Item dataitem OnPreDataItem trigger of Report 99001017 "Calculate Plan - Plan. Wksh." immediately after SetAtStartPosition := true.

trigger OnPreDataItem()
            var
                ShouldSetAtStartPosition: Boolean;
            begin
                OnBeforeItemOnPreDataItem(Item);

                if GuiAllowed then
                    OpenWindow();

                Clear(CalcItemPlan);
                CalcItemPlan.SetTemplAndWorksheet(CurrTemplateName, CurrWorksheetName, NetChange);
                CalcItemPlan.SetParm(UseForecast, ExcludeForecastBefore, Item);
                CalcItemPlan.Initialize(FromDate, ToDate, MPS, MRP, RespectPlanningParm);

                SetAtStartPosition := true;
                OnAfterSetAtStartPositionOnPreDataItem(Item);

                ReqLine.SetRange("Worksheet Template Name", CurrTemplateName);
                ReqLine.SetRange("Journal Batch Name", CurrWorksheetName);
                PlanningErrorLog.SetRange("Worksheet Template Name", CurrTemplateName);
                PlanningErrorLog.SetRange("Journal Batch Name", CurrWorksheetName);
                ShouldSetAtStartPosition := PlanningErrorLog.FindFirst() and ReqLine.FindFirst();
                OnOnPreDataItemOnAfterCalcShouldSetAtStartPosition(Item, PlanningErrorLog, ReqLine, SetAtStartPosition, ShouldSetAtStartPosition);
                if ShouldSetAtStartPosition then
                    SetAtStartPosition := not Confirm(Text009);

                ClearPlanningErrorLog();
                ClearLastError();

                OnAfterItemOnPreDataItem(Item);
                Commit();
            end;

Event Signature:

[IntegrationEvent(false, false)]
local procedure OnAfterSetAtStartPositionOnPreDataItem(var Item: Record Item; var MarkedItem: Record Item)
begin
end;

Alternatives evaluated: OnBeforeItemOnPreDataItem fires too early before planning setup is complete. OnAfterItemOnPreDataItem fires too late after Commit(). No event currently exists between SetAtStartPosition := true and the ReqLine/PlanningErrorLog filter block in Report 99001017.

Metadata

Metadata

Assignees

No one assigned

    Labels

    missing-infoThe issue misses information that prevents it from completion.

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions