web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

AL Page Variable Not Refreshing Instantly on OnLookup Trigger

(0) ShareShare
ReportReport
Posted on by 74

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

 

  1. On my page ("G/L Creation Request Card"), I have a field that displays a global variable: AccountSubcategoryDescription.
  2. This variable is populated by a procedure GetSubcategoryDescription() which is called in the OnAfterGetRecord trigger.
  3. The user can change this value using an OnLookup trigger.

 

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?

 

I have the same question (0)
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    19,922 Super User 2025 Season 2 on at
    AL Page Variable Not Refreshing Instantly on OnLookup Trigger
    Just call your procedure after you’ve updated the record, then update the page. Try with this once and check

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Sumit Singh Profile Picture

Sumit Singh 2,179

#2
OussamaSabbouh Profile Picture

OussamaSabbouh 1,999

#3
YUN ZHU Profile Picture

YUN ZHU 1,892 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans