Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,20 @@ using Microsoft.Finance.GeneralLedger.Ledger;

pageextension 22204 "General Ledger Entries Review" extends "General Ledger Entries"
{
layout
{
addafter(Amount)
{
field(RemainingAmount; RemainingAmount)
{
ApplicationArea = Basic, Suite;
Caption = 'Remaining Amount';
Editable = false;
ToolTip = 'Specifies the remaining amount that can be reviewed.';
}
}
}

actions
{
addfirst("Ent&ry")
Expand All @@ -29,4 +43,13 @@ pageextension 22204 "General Ledger Entries Review" extends "General Ledger Entr
}
}
}

trigger OnAfterGetRecord()
begin
Rec.CalcFields("Reviewed Amount");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code was flagged by agent:
Issue
CalcFields() called inside OnAfterGetRecord trigger on G/L Entry table (10M+ rows). This creates N+1 query pattern where every row displayed triggers a separate FlowField calculation query, causing severe performance degradation during page scrolling and rendering.

Recommendation
Remove explicit CalcFields() from OnAfterGetRecord. If 'Reviewed Amount' is a FlowField, bind it directly to a page field - the platform handles FlowField loading more efficiently. Ensure the FlowField's source table has a proper SIFT index (key with SumIndexFields) to optimize the aggregation. If RemainingAmount calculation is required, consider computing it only OnAfterGetCurrRecord (for the focused record) or using a query-based approach.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JesperSchulz
Well if I put the field on the page and people are making it invisible it would not calculate because of the feature:
" Calculate only visible FlowFields"
ANd on the OnAfterGetCurreRecord I only have the focussed record

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback from the Finance team:

This feature has given us enormous performance issues, inconsistent calculation of Amount to Review and upgrade timeouts. We will not add more calculation to it. These fields are an extension on top of GL Entry - one of the biggest tables of BC with millions of records. Extremely risky to add more calculations.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JesperSchulz I can understand it. Maybe close this PR.
But then we also need to close the BC idea with the comment about the performance.

RemainingAmount := Rec.Amount - Rec."Reviewed Amount";
end;

var
RemainingAmount: Decimal;
}
Loading