microsoft / microsoft/BCApps

Add OnAfterMatrixOnAfterGetRecord event to page 9229 "Res. Avail. (Service) Matrix"

Open
#11,130 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Approved event-request ext-ready-to-implement Team: SCM
Dominant language
AL
Stars
683
Forks
459
Avg merge
3d 26m
Merged PRs (30d)
633

Description

Why do you need this change?
Request

Please add an OnAfterMatrixOnAfterGetRecord integration event to page 9229
"Res. Avail. (Service) Matrix".

Business scenario

We extend resource availability with hours allocated to assembly orders. These
hours must be deducted from every calculated availability cell in the matrix.

The calculation is based on a custom FlowField on the Resource table, filtered
by the current resource and each matrix column's date filter.

Current extensibility limitation

Page 9229 currently exposes the following event:

[IntegrationEvent(false, false)]
local procedure OnBeforeMatrixOnAfterGetRecord(
var MatrixRec: Record Resource;
var MATRIX_CellData: array[32] of Decimal;
var MatrixColumnDateFilters: array[32] of Record Date;
var IsHandled: Boolean)
begin
end;

This event is raised before the standard procedure initializes MatrixRec with
the current page record:

MatrixRec.Reset();
MatrixRec.SetRange("No.", Rec."No.");

The subscriber therefore has no access to the resource represented by the
current row (Rec."No."). It cannot safely replace the standard calculation
using IsHandled := true.

Changing the signature of the existing event could be a breaking change for
existing subscribers. A new event after the standard calculation would avoid
that compatibility risk.

Describe the request

Please raise the following event at the end of
MatrixOnAfterGetRecord(), after the standard matrix cells have been
calculated and before or after SetVisible():

[IntegrationEvent(false, false)]
local procedure OnAfterMatrixOnAfterGetRecord(
Resource: Record Resource;
var MatrixCellData: array[32] of Decimal;
MatrixColumnDateFilters: array[32] of Record Date)
begin
end;

Suggested placement:

local procedure MatrixOnAfterGetRecord()
var
I: Integer;
IsHandled: Boolean;
begin
IsHandled := false;
OnBeforeMatrixOnAfterGetRecord(MatrixRec, MATRIX_CellData, MatrixColumnDateFilters, IsHandled);
if IsHandled then
exit;

MatrixRec.Reset();
MatrixRec.SetRange("No.", Rec."No.");
for I := 1 to ArrayLen(MatrixColumnDateFilters) do begin
    MATRIX_CellData[I] := 0;
    MatrixRec.SetRange(
        "Date Filter",
        MatrixColumnDateFilters[I]."Period Start",
        MatrixColumnDateFilters[I]."Period End");
    if MatrixRec.Find('-') then
        repeat
            MatrixRec.CalcFields(Capacity, "Qty. on Service Order");
            MATRIX_CellData[I] := MatrixRec.Capacity - MatrixRec."Qty. on Service Order";
        until MatrixRec.Next() = 0;
end;

OnAfterMatrixOnAfterGetRecord(Rec, MATRIX_CellData, MatrixColumnDateFilters);

SetVisible();

end;

Example extension usage:

[EventSubscriber(
ObjectType::Page,
Page::"Res. Avail. (Service) Matrix",
OnAfterMatrixOnAfterGetRecord,
'',
false,
false)]
local procedure ResAvailServiceMatrix_OnAfterMatrixOnAfterGetRecord(
Resource: Record Resource;
var MatrixCellData: array[32] of Decimal;
MatrixColumnDateFilters: array[32] of Record Date)
var
ResourceForCalculation: Record Resource;
ColumnNo: Integer;
begin
ResourceForCalculation.SetRange("No.", Resource."No.");

for ColumnNo := 1 to ArrayLen(MatrixColumnDateFilters) do begin
    ResourceForCalculation.SetRange(
        "Date Filter",
        MatrixColumnDateFilters[ColumnNo]."Period Start",
        MatrixColumnDateFilters[ColumnNo]."Period End");
    ResourceForCalculation.CalcFields("Qty.onAssemblyOrderAlloc._pte");

    MatrixCellData[ColumnNo] -=
        ResourceForCalculation."Qty.onAssemblyOrderAlloc._pte";
end;

end;

Provide an implementation (optional)
  • I will provide the implementation for this extensibility request

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Open page 9229, "Res. Avail. (Service) Matrix", and inspect MatrixOnAfterGetRecord along with the existing OnBeforeMatrixOnAfterGetRecord event. Add the requested after-calculation integration event with the stated parameters, then verify that an event subscriber can adjust the calculated matrix cells for the current resource and date filters.

Written by the indexing model from the issue text.

Assessment

Domain
backend-api-design
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.