How to change the font color in Business Central?

isabtogumon
Member Posts: 50
Hello everyone,
Is it possible to change the color of the font, as shown in the image? In this example the font color changed because the invoice expired. How can I change the font color to yellow five days before the document expires?

Is it possible to change the color of the font, as shown in the image? In this example the font color changed because the invoice expired. How can I change the font color to yellow five days before the document expires?

0
Best Answer
-
Other than hard coding the document number, that looks pretty good to me5
Answers
-
One of those things that are on my list to figure out but haven't gotten to yet. I don't know exactly how it works for conditional formatting but it has something to do with the Style and StyleExpr properties on page objects.
Maybe this will get you started:
https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/properties/devenv-style-property0 -
I have only tried it in the windows client and it works there.
As DenSter already mentioned it has to do with the Style and StyleExpr properties that the fields on a page have.
I created a global variable "TxtStyleExpr" of type Text with no length.
On the page, I put that variable, "TxtStyleExpr" in the property "StyleExpr" leaving "Style" on <none>.
Then in code I use that text variable in the OnAfterGetRecord:TxtStyleExpr := 'Standard'; // Default IF (BooOrderExpired) THEN TxtStyleExpr := 'Unfavorable'; // Bold Red IF (BooOrder5DayNotice) THEN TxtStyleExpr := 'Ambiguous'; // Orange
You can only use the styles that are defined by Microsoft.
The URL that DenSter provided has a list that defines them.0 -
I have only tried it in the windows client and it works there.
As DenSter already mentioned it has to do with the Style and StyleExpr properties that the fields on a page have.
I created a global variable "TxtStyleExpr" of type Text with no length.
On the page, I put that variable, "TxtStyleExpr" in the property "StyleExpr" leaving "Style" on <none>.
Then in code I use that text variable in the OnAfterGetRecord:TxtStyleExpr := 'Standard'; // Default IF (BooOrderExpired) THEN TxtStyleExpr := 'Unfavorable'; // Bold Red IF (BooOrder5DayNotice) THEN TxtStyleExpr := 'Ambiguous'; // Orange
You can only use the styles that are defined by Microsoft.
The URL that DenSter provided has a list that defines them.
I have used your example, it did not go well, the font color has not changed, this is the code I have writtentrigger OnAfterGetRecord(); begin MyStyleExpr := 'Standard'; if ("Document No." = 'FVR00043') then MyStyleExpr := 'Ambiguous'; end; var MyStyleExpr: Text;
Can you tell me what I need to make it work well?0 -
Works for me:
Did you set the StyleExpr property to your MyStyleExpr variable? I set it at a field level. In the screenshot you see that only No and Name are formatted, those are the fields that I set the StyleExpr property.0 -
Thanks DenSter,
I added the property to the field and it worked, I consider that was what was missing. I did it this way, could you tell me if it is the right way?layout { // Add changes to page layout here modify("Document No.") { StyleExpr = MyStyleExpr; } modify("Document Type") { StyleExpr = MyStyleExpr; } } var MyStyleExpr: Text; trigger OnAfterGetRecord(); begin MyStyleExpr := 'Standard'; if ("Document No." = 'FVR00043') then MyStyleExpr := 'Ambiguous'; end;
0 -
Other than hard coding the document number, that looks pretty good to me5
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions