Announcements
No record found.
AI was used to create this answer Yes, you can change the color of a label on a form in Microsoft Dynamics 365 Business Central (BC) using AL code. However, note that the ability to customize colors directly on labels is limited in the base functionality of BC. You can achieve this by using the Style and StyleExpr properties for controls on pages or reports.
Here’s how you can do it:
Open the AL Project:
Open your AL project in Visual Studio Code or the development environment you are using.
Locate the Page or Report:
Find the page or report where the label is located.
Use the Style and StyleExpr Properties:
Style
StyleExpr
Use the Style property to define the appearance of the control (e.g., label, field).
Use the StyleExpr property to dynamically set the style based on a condition.
Here’s an example of how to change the color of a label on a page:
page 50100 "My Custom Page" { layout { area(Content) { field("My Field"; "My Field") { ApplicationArea = All; Style = Strong; // Applies a strong (bold) style StyleExpr = ShouldHighlight; // Dynamically applies style based on a condition } label(MyLabel) { ApplicationArea = All; Caption = 'This is a colored label'; Style = Favorable; // Applies a green color } } } var ShouldHighlight: Boolean; trigger OnAfterGetRecord() begin // Set the condition for dynamic styling ShouldHighlight := "My Field" > 100; end; }
The Style property supports the following options:
Standard: Default style.
Strong: Bold text.
Attention: Red color (used for warnings or errors).
Favorable: Green color (used for positive indicators).
Unfavorable: Red color (used for negative indicators).
Ambiguous: Yellow color (used for warnings or uncertain states).
Subordinate: Gray color (used for less important information).
The Style property is primarily designed for fields, not labels. For labels, you can only use the Style property if the label is part of a field or group.
If you need more advanced customization (e.g., custom colors), you may need to use client-side extensions or JavaScript for additional styling.
If you need more flexibility, consider using a field with a Caption instead of a label. Fields support the Style and StyleExpr properties, allowing you to change colors dynamically.
Caption
field("Dummy Field"; '') { ApplicationArea = All; Caption = 'This is a colored label'; Editable = false; Style = Favorable; // Applies a green color }
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.
Congratulations to our 2026 Super Stars!
We are thrilled to have these Champions in our Community!
These are the community rock stars!
Stay up to date on forum activity by subscribing.
ManoVerse 130 Super User 2026 Season 1
11manish 117
Muhammad Shahzad Sh... 69 Most Valuable Professional