Add OnAfterMatrixOnAfterGetRecord event to page 9229 "Res. Avail. (Service) Matrix"
Nobody has claimed this yet.
- Dominant language
- AL
- Stars
- 683
- Forks
- 459
- Avg merge
- 3d 26m
- Merged PRs (30d)
- 633
Description
Why do you need this change?
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
Proposed event
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with page 9229, "Res. Avail. (Service) Matrix", and read its existing OnBeforeMatrixOnAfterGetRecord event and MatrixOnAfterGetRecord procedure. Verify that the new event is raised after the standard matrix cells are calculated, exposes the current resource and cell data, and allows subscribers to adjust the results without changing the existing event.
Written by the indexing model from the issue text.
Assessment
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100