Change Field color based on field value in Dynamics 365 Business central

Hello Everyone.
Previously, I received a request from a client who wanted to change the color of a field based on its value. Here are the details.

What’s the best way to achieve this?
In this post, I would like to present one possible solution.
Despite certain limitations, I suggest utilizing the StyleExpr property of the field. This is a built-in feature of Business Central, ensuring that performance remains unaffected.
Now, let’s examine the source code in detail.
To start, I added a new field to the Vendor table.
Level:

Enum Object :

Show this field On the Vendor Card and Vendor List Pages.
Use a variable to control property of StyleExpr.


Simply Created a Codeunit to Return Different Property value based on field Value.

call this Codeunit On the Vendor List page .

Call this Codeunit On The Vendor card page

Publish.

Confirm On The Page.
Vendor List:

Vendor Card:

Hope this Will help.
Thanks.