Hi, Readers.
The public preview for Dynamics 365 Business Central 2024 release wave 2 (BC25) is available. Learn more: Link.
I will continue to test and share some new features that I hope will be helpful.
In this post, I would like to talk about new type PageStyle in Business Central 2024 release wave 2 (BC25). This is not yet documented in the Business Central 2024 release wave 2 (BC25) release plan. But it is mentioned in AL Language extension changelog Version 14.0
The type can be used to get the valid values for StyleExpr, found on page controls. Here is an example of how to use it:
https://marketplace.visualstudio.com/items/ms-dynamics-smb.al/changeloglayout { area(Content) { field(Name; rec.Name) { StyleExpr = nameStyle; } } } var nameStyle : Text; local procedure ChangeNameStyle(newPageStyle : PageStyle) begin nameStyle := format(newPageStyle); end;
For example,
Microsoft hasn’t provided much information about this new data type yet. Here’s my current understanding, I hope it helps.
As you know, in Business Central, we can control the color and font displayed on the page through the following two properties.
Style Property: Sets a value that determines how text in a field on a page is formatted.
Value | Available or changed with | Description |
---|---|---|
None | runtime version 1.0 | None |
Standard | runtime version 1.0 | Standard |
StandardAccent | runtime version 1.0 | Blue |
Strong | runtime version 1.0 | Bold |
StrongAccent | runtime version 1.0 | Blue + Bold |
Attention | runtime version 1.0 | Red + Italic |
AttentionAccent | runtime version 1.0 | Blue + Italic |
Favorable | runtime version 1.0 | Bold + Green |
Unfavorable | runtime version 1.0 | Bold + Italic + Red |
Ambiguous | runtime version 1.0 | Yellow |
Subordinate | runtime version 1.0 | Grey |
StyleExpr Property: Sets whether the format that is specified in the Style Property is applied to text in a field.
For example, in the standard Customer Ledger Entries, the Due Date is used to determine the font/color displayed on the page.
We also discussed a similar topic before, more details: Change field color based on field value in Dynamics 365 Business Central
You can find that whether it is Microsoft documentation, BC standard code, or my example, the value of StyleExpr Property is hard-coded. This will not work if we misspell the text, Unfavorable, Ambiguous or etc.
Well, this has changed in this wave (BC25), new data type PageStyle. You can see that this data type contains all 11 values in the Style Property.
This type looks like an Enum or Option type internally.
PS:
Cannot implicitly convert type ‘PageStyle’ to ‘Text’AL AL0122
So now we can easily do the following.
Test video:
Great, give it a try!!!😁
Test code:
pageextension 50100 ItemListExt extends "Item List"
{
layout
{
modify(Description)
{
StyleExpr = nameStyle;
}
}
actions
{
addafter(AdjustInventory)
{
action(StandardAccent)
{
ApplicationArea = All;
Caption = 'StandardAccent';
Image = Change;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
begin
ChangeNameStyle(PageStyle::StandardAccent);
end;
}
action(Strong)
{
ApplicationArea = All;
Caption = 'Strong';
Image = Change;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
begin
ChangeNameStyle(PageStyle::Strong);
end;
}
action(Favorable)
{
ApplicationArea = All;
Caption = 'Favorable';
Image = Change;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
begin
ChangeNameStyle(PageStyle::Favorable);
end;
}
action(Ambiguous)
{
ApplicationArea = All;
Caption = 'Ambiguous';
Image = Change;
Promoted = true;
PromotedCategory = Process;
trigger OnAction()
begin
ChangeNameStyle(PageStyle::Ambiguous);
end;
}
}
}
var
nameStyle: Text;
local procedure ChangeNameStyle(newPageStyle: PageStyle)
begin
nameStyle := Format(newPageStyle);
end;
}
END
Hope this will help.
Thanks for reading.
ZHU
コメント