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...
Answered

Dynamic change of row color

(0) ShareShare
ReportReport
Posted on by 104

Hi. How can I change dynamically color of rows on the list page?

The color depends of global variable. I assigned color (variable) to each record in OnAfterGetRecord trigger - this part works correctly.

After Modify record I need to update color of modified row. I try to do this in OnModifyRecord trigger but it does not work. If I add CurrPage.Update() method - I get memory error on the page in BC.

   field("Quantity"; Rec."Quantity")
  {
    ApplicationArea = Manufacturing;
    StyleExpr = Color;
   }
    trigger OnAfterGetRecord()
    begin
        if Rec."Quantity" < Rec."Total Qty." then
            Color := 'attention'
        else
            Color := 'standard';
    end;
This part does not work:
    trigger OnModifyRecord(): Boolean
    begin
        if Rec."Quantity" < Rec."Total Qty." then
            Color := 'attention'
        else
            Color := 'standard';
    end;
I have the same question (1)
  • Suggested answer
    Nitin Verma Profile Picture
    21,812 Moderator on at

    Hi,

    Please write your color code in OnafterGetcurrRecord trigger.

    Thanks.

  • greex Profile Picture
    104 on at

    thank you! It works better, but unfortunately still not good enough - if I use OnAfterGetCurrRecord I need to select any other row and again select modified row to update the color. How to do this automatically immediately after update field?

  • Suggested answer
    DAnny3211 Profile Picture
    11,421 Super User 2026 Season 1 on at

    hello

    try putting after your code

    cuurPage.update

    DAniele

  • greex Profile Picture
    104 on at

    Don't work

    Error: Sorry, we just updated this page. Reopen it, and try again.

    Page  has to close.

  • Verified answer
    DAnny3211 Profile Picture
    11,421 Super User 2026 Season 1 on at
    CIao

    try this

    I replicated it on NAV and it works

    it seems to me that:

    trigger OnModifyRecord(): Boolean
    begin
    if Rec. "Quantity" < Rec. "Total Qty." then
      Colour := 'attention'
    else
      Colour := 'standard';
    end;

    is quite useless, it is not needed on the omodify, so change it like this:

    trigger OnModifyRecord(): Boolean
    begin
      CurrPage.UPDATE(FALSE);
    end;
    then you only need to put it on this trigger:

    trigger OnAfterGetRecord()
    begin
      if Rec. "Quantity" < Rec. "Total Qty." then
        Colour := 'attention'
      else
        Color := 'standard';
    end;

    check my answer if it helped you, thanks

    DAniele
  • greex Profile Picture
    104 on at

    It works perfectly! Thank you very much :)!

  • Suggested answer
    DAnny3211 Profile Picture
    11,421 Super User 2026 Season 1 on at

    hi

    check my answer if it helped you, thanks

    DAniele

  • Suggested answer
    YUN ZHU Profile Picture
    101,126 Super User 2026 Season 1 on at

    Hi, just adding some info.

    Change field color based on field value in Dynamics 365 Business Central

    https://yzhums.com/1599/

    Hope this helps 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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,138 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,279 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,192

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans