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

Announcements

No record found.

News and Announcements icon
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

(6) ShareShare
ReportReport
Posted on by 104

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
    22,098 Super User 2026 Season 1 on at
    Just call your procedure after you’ve updated the record, then update the page. Try with this once and check
  • Suggested answer
    OussamaSabbouh Profile Picture
    12,760 Super User 2026 Season 1 on at
    Hello,
     
    CurrPage.Update(false) doesn’t refresh variables — only table fields.
    After updating your record, call:
     
    GetSubcategoryDescription();
    CurrPage.Update(false);
     
    Or bind the field to a table/FlowField instead.
     
    Regards,
    Oussama Sabbouh
  • Suggested answer
    Aman Kakkar Profile Picture
    2,977 Super User 2026 Season 1 on at

    Hi,

    In your OnLookup trigger, after calling Rec.Modify(), make sure to call your GetSubcategoryDescription() procedure again before CurrPage.Update(false).
     
    This ensures that your variable is refreshed immediately after the record is modified.
     
    Also, don’t remove the same function call from the OnAfterGetRecord() trigger — it’s still needed when the page initially loads or data is refreshed.
     
    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
            Rec.Validate("Account Subcategory", Format(TempGLAccountCategory."Entry No."));
            Rec.Modify(true);
    
            GetSubcategoryDescription(); // refresh variable here
    
            CurrPage.Update(false);
            exit(true);
        end;
        exit(false);
    end;
    
     
    Hope this helps.
    Aman K
  • Suggested answer
    YUN ZHU Profile Picture
    99,049 Super User 2026 Season 1 on at
    There's also an ultimate solution: close and reopen the page.
    For example,
     
    Hope this can give you some hints as well.
    Thanks.
    ZHU

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,804 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,103 Super User 2026 Season 1

#3
Kamal Khakhkhar Profile Picture

Kamal Khakhkhar 695

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans