How To: Color fields on pages for NAV2013 or superior

Featured
FacebookTwitterGoogle+LinkedInWhatsAppEvernoteShare

With the introduction of the new Role Tailored Client a few years ago, we gained a lot of things and were able to include many new and exciting features. The RTC client has as an advantage that no matter what type of screen the page is being shown in, it will resize itself to present a usable user interface, among others.

However, with the changes the new client brought, some sacrifices had to be made. Among those sacrificies we lost the ability to define colors, sizes, positions, etc of the different elements that make a form/page.

At the time being, the NAV versions available have different coloring options:

  • Standard
  • StandardAccent:
  • Strong
  • StrongAccent
  • Attention
  • AttentionAccent
  • Favorable
  • Unfavorable
  • Ambiguous
  • Subordinate

(click the image to enlarge it)

Colors

 

In the image we can appreciate how the cells have a specific formatting to it.

How can we do this?

It’s rather simple, really. The only thing we must do is go to the design of the page and define what kind of style we want on the property “Style” of the control we want to color.

Style
Beautiful! Now we’ve learned to color our pages and fields how we want.

But what  if we want to apply that color dynamically depending on the content of the field, or some other condition?

In order to do this we must do as follows in the page:

1.- Declare a boolean variable and set the property of the variable IncludeInDataset = Yes. The name of my variable is “LocationCodeIsAzul”.

IncludeInDataset

2.- Set the code that will set the newly created boolean variable in the OnAfterGetRecord() trigger of the page. In the case of the example my condition is as follows:

OnAfterGetRecord

3.- Go to the properties of the control you want to color depending on this variable and set it as the value of the property StyleExpr.

StyleExpr

 

4.- And now all that is left is saving/compiling and executing the page.

StyleExprExampleWe can see how only the records which have the value “AZUL” in the “Location Code” field have the “Location Code” field in bold letters.

 

And that’s it!

 

Leave a Comment.