[Master] - [Expense Agent] Fix saving Expense Location after category change - #10984
[Master] - [Expense Agent] Fix saving Expense Location after category change#10984v-rohangarg20 wants to merge 1 commit into
Conversation
|
Could not find a linked ADO work item. Please link one by using the pattern 'AB#' followed by the relevant work item number. You may use the 'Fixes' keyword to automatically resolve the work item when the pull request is merged. E.g. 'Fixes AB#1234' |
Good Sense Reviewer - Round 1Recommendation: Accept with SuggestionsWhat this PR doesThis change removes the page-level Expense Location validation trigger from the Expense Report subpage. The table validation still saves the selected location and applies the rule, but the page no longer does an extra CurrPage.Update() that can try to save an outdated line after rule evaluation changed the record. Problem-solution fitFit: Strong The reported scenario is a stale page record when a line is changed to a per diem category and then an expense location is selected. Removing the redundant page refresh fits that scenario and leaves the existing field validation in the table as the single save path. SuggestionsS1 (🟠 Moderate): Add a page regression test Risk assessment and necessityRisk: The change is limited to ExpenseReportSubPage.Page.al, but it affects an editable field whose table trigger can update rule, amount, and per diem details. The main risk is a UI regression where related totals or rule state do not refresh immediately after the location is changed. Necessity: The change is needed because an extra page refresh after field validation can create a second save of an outdated record. The scope is narrow and keeps the business validation in the table trigger.
|
|
Removing the page field OnValidate trigger from "Expense Location" drops the explicit CurrPage.Update() refresh, even though the table's OnValidate for "Expense Location" (ExpenseReportLine.Table.al) still mutates sibling fields that are also shown on this same subpage: it auto-populates "Starting Date and Time" and "Ending Date and Time" when they are blank, and calls ApplyRule() which can change "Rule Violations"/"Applied Rule Id"-driven state. Both "Starting Date and Time" (line 204) and "Ending Date and Time" (line 215) are rendered as fields on this page. Without CurrPage.Update(), a user validating "Expense Location" will not see these dependent fields refresh immediately in the UI until the record is otherwise re-read (e.g. navigating away and back). Recommend restoring the trigger, or confirming/documenting that the platform already refreshes the row after Validate() in this scenario. Suggested fix (apply manually — could not be anchored as a one-click suggestion): field("Expense Location"; Rec."Expense Location")
{
ApplicationArea = Basic, Suite;
ToolTip = 'Specifies where the expense occurred. Available when the expense requires per diem details.';
ShowMandatory = IsPerDiemCategory;
Editable = IsPerDiemCategory;
trigger OnValidate()
begin
CurrPage.Update();
end;
}Line mapping was unavailable, so this was posted as an issue comment. 👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.38.6 |
Fixes AB#648711
Problem
Saving an Expense Location after changing an Expense Report Line from a Meals category to a Per-diem category could result in a stale-record error.
Fix
Removed the redundant page-level
OnValidatetrigger forExpense Location, which calledCurrPage.Update(). The standard field validation now saves the selected location without an extra page refresh or second save.Validation