How to change the font colour of a List page based on a condition in Dynamics NAV - CloudFronts

How to change the font colour of a List page based on a condition in Dynamics NAV

Intoduction:

The requirement was such that, based on a condition certain lines should appear in Red.This can be done by using page control Style Property. The Style property has ten values that apply different formats to field text as below:

Value Format
Standard Standard
StandardAccent Blue
Strong Bold
StrongAccent Blue + Bold
Attention Red + Italic
AttentionAccent Blue + Italic
Favorable Bold + Green
Unfavorable Bold + Italic + Red
Ambiguous Yellow
Subordinate Grey

Pre-Requisites:

Microosft Dynamics NAV 2017

Steps:

1. Create a global variable i.e. on the View menu, choose C/AL Globals.

2. Define the variable, and then set the DataType to Boolean.

3. Open the Property of the variable then set the IncludeInDataSet to Yes. (I’ve use CFS_Repo as my boolean field).

4. Create a local function. (in my case UpdateStyle).

5. Now, code in the function. My requiremnt was such that if field  RepoInitiated is true then the line should should appear red. You can code as per tour requirement.

6. On the trigger OnAfterGetCurrRecord, call the function.

7. Now select the Field in the List page and click on Properties (Shift + F4)

8. Set the Style to Unfavorable and StyleExpr to CFS_Repo (the boolean field )

9. Repeat the step 8 for all fields present on the list page.


Share Story :

Secured By miniOrange