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:
(click the image to enlarge 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.
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”.
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:
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.
4.- And now all that is left is saving/compiling and executing the page.
And that’s it!