Add OnAfterMatrixOnAfterGetRecord event to page 9229 "Res. Avail. (Service) Matrix"
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
✅ Analysis complete - ready for further processing
Implementation:
Add a new integration event at the end of MatrixOnAfterGetRecord() in page 9229 Res. Avail. (Service) Matrix so extensions can adjust the calculated matrix cell values for the current resource row after the standard calculation completes.
Location in MatrixOnAfterGetRecord() procedure:
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 begin
MatrixRec.CalcFields(Capacity);
MATRIX_CellData[I] := MatrixRec.Capacity;
end;
end;
SetVisible();
OnAfterMatrixOnAfterGetRecord(Rec, MATRIX_CellData, MatrixColumnDateFilters); // NEW
end;
Event Publisher (add at the end of the codeunit with other events):
[IntegrationEvent(false, false)]
local procedure OnAfterMatrixOnAfterGetRecord(Resource: Record Resource; var MatrixCellData: array[32] of Decimal; MatrixColumnDateFilters: array[32] of Record Date)
begin
end;
File: ResAvailServiceMatrix.Page.al
[!NOTE] Automatically generated by the Triage Agent — advisory only. An engineer will review before any action is taken.
[!TIP] Is the triage result incorrect? Reply with
/not-accurateand briefly explain what was wrong. Your feedback improves future responses.
I want to avoid duplicating standard code.