Hello everyone,
I'm having an issue on a Card page where a field displaying a variable won't refresh its value immediately. I have to close and reopen the page to see the new value.
My Setup
- On my page (
"G/L Creation Request Card"), I have a field that displays a global variable:AccountSubcategoryDescription. - This variable is populated by a procedure
GetSubcategoryDescription()which is called in theOnAfterGetRecordtrigger. - The user can change this value using an
OnLookuptrigger.
The Problem
When the OnLookup trigger runs, my code correctly updates the underlying record (Rec."Account Subcategory") and saves it with Rec.Modify(true).
However, the AccountSubcategoryDescription variable on the page does not update. It stays blank (or shows the old value) until I close and reopen the card.
My Code
Here is the relevant code from my page.
Page Variables:
var
AccountSubcategoryDescription: Text[100];
GLAccountCategory: Record "G/L Account Category";
Page Field and OnLookup Trigger:
field(AccountSubcategory; AccountSubcategoryDescription)
{
ApplicationArea = All;
Caption = 'Account Subcategory';
Editable = PageEditable;
trigger OnLookup(var Text: Text): Boolean
var
TempGLAccountCategory: Record "G/L Account Category";
begin
if PAGE.RunModal(PAGE::"G/L Account Categories", TempGLAccountCategory) = ACTION::LookupOK then begin
// 1. This updates the underlying record
Rec.Validate("Account Subcategory", Format(TempGLAccountCategory."Entry No."));
Rec.Modify(true);
// 2. I thought this would refresh the page, but it doesn't
CurrPage.Update(false);
exit(true);
end;
exit(false);
end;
}
Triggers that load the variable:
trigger OnAfterGetRecord()
begin
// This line loads the description from the record
GetSubcategoryDescription();
end;
local procedure GetSubcategoryDescription()
var
SubCategoryEntryNo: Integer;
begin
AccountSubcategoryDescription := '';
if Rec."Account Subcategory" <> '' then begin
Evaluate(SubCategoryEntryNo, Rec."Account Subcategory");
if GLAccountCategory.Get(SubCategoryEntryNo) then
AccountSubcategoryDescription := GLAccountCategory.Description;
end;
end;
My Question
Why isn't CurrPage.Update(false) forcing my page to re-run OnAfterGetRecord and update my variable?
What is the correct way to make the AccountSubcategoryDescription variable refresh instantly after the OnLookup trigger finishes?


Report
All responses (
Answers (