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;
  • Suggested answer
    YUN ZHU Profile Picture
    85,338 Super User 2025 Season 1 on at
    RE: Dynamic change of row color

    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

  • Suggested answer
    DAnny3211 Profile Picture
    9,278 Moderator on at
    RE: Dynamic change of row color

    hi

    check my answer if it helped you, thanks

    DAniele

  • greex Profile Picture
    104 on at
    RE: Dynamic change of row color

    It works perfectly! Thank you very much :)!

  • Verified answer
    DAnny3211 Profile Picture
    9,278 Moderator on at
    RE: Dynamic change of row color
    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
    RE: Dynamic change of row color

    Don't work

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

    Page  has to close.

  • Suggested answer
    DAnny3211 Profile Picture
    9,278 Moderator on at
    RE: Dynamic change of row color

    hello

    try putting after your code

    cuurPage.update

    DAniele

  • greex Profile Picture
    104 on at
    RE: Dynamic change of row color

    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
    Nitin Verma Profile Picture
    21,567 Moderator on at
    RE: Dynamic change of row color

    Hi,

    Please write your color code in OnafterGetcurrRecord trigger.

    Thanks.

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

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,655

#2
Mansi Soni Profile Picture

Mansi Soni 1,574

#3
YUN ZHU Profile Picture

YUN ZHU 1,453 Super User 2025 Season 1

Featured topics

Product updates

Dynamics 365 release plans