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

Notifications

Announcements

No record found.

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,698 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,397 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,397 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,397 on at

    hi

    check my answer if it helped you, thanks

    DAniele

  • Suggested answer
    YUN ZHU Profile Picture
    95,329 Super User 2025 Season 2 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

Responsible AI policies

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

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,229

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,867 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,153 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans