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...
Suggested answer

need to change font color based on some condition

(0) ShareShare
ReportReport
Posted on by 2,047

Hi,

I need to highlight the general journal lines field[shortcut dimension 1 code] based on some filter and I tried to write code for that but it didn't work as expected.

you can see in the below screen print I tried this two-way, one is to create a custom action and write the logic in that, and the second is using the standard trigger of Microsoft.

pastedimage1671448132381v5.png

pastedimage1671448153662v6.png

pastedimage1671448178096v7.png

pastedimage1671448193453v8.png

Note: here GetCorporateId() is my custom procedure and it is working as expected.

This above code didn't work as expected, it has been populated with red color in all the lines, But what I need is when the Corporate id is 14 then I need to highlight the 'shortcut dimension 1 field' with red color otherwise none.

Can anyone tell us what is the missing part in this code?

  • Suggested answer
    YUN ZHU Profile Picture
    82,109 Super User 2025 Season 1 on at
    RE: need to change font color based on some condition

    Hi, hope the following helps.

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

    https://yzhums.com/1599/

    Thanks.

    ZHU

  • Suggested answer
    pankaj.k Profile Picture
    974 on at
    RE: need to change font color based on some condition

    Hi Inkey

    Check with my answer 

    7356.Capture.PNG

    New Field Value must be Standard or Unfavorable.

  • Inkey Solutions Profile Picture
    2,047 on at
    RE: need to change font color based on some condition

    Hi Daniele Incalza,

    Your answer is works for me but when I try to insert new other lines it will give me the below error.

    pastedimage1671455583926v1.png

    Thank you.

  • Suggested answer
    DAnny3211 Profile Picture
    9,276 Moderator on at
    RE: need to change font color based on some condition

    CIao

    use the second and enter onmodify on the page

    CurrPage.UPDATE(FALSE);

    if that doesn't work, check the getcorporateid function again, I don't want there to be anything wrong with it

    DAniele

  • Suggested answer
    pankaj.k Profile Picture
    974 on at
    RE: need to change font color based on some condition

    Hi Inkey,

    everything is fine but you need to do some more customization for this Please check below steps.

    Step1: Create one new Text filed For Storing the data Standard or Unfavorable.

    Step2: Assign StyleEXpr to your NewField. (StyleExpr = NewField;)

    Add my suggestion  with your customization that will work.

  • Suggested answer
    Nitin Verma Profile Picture
    21,544 Moderator on at
    RE: need to change font color based on some condition

    Hi,

    Please always put your code in text format not in image.

    put your code on OnAfterGetCurrRecord too.

    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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,459 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 233,066 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans