Hello everyone,
Is it possible to change the color of the font, as shown in the image? In this example the font color changed because the invoice expired. How can I change the font color to yellow five days before the document expires?
One of those things that are on my list to figure out but haven't gotten to yet. I don't know exactly how it works for conditional formatting but it has something to do with the Style and StyleExpr properties on page objects.
I have only tried it in the windows client and it works there.
As DenSter already mentioned it has to do with the Style and StyleExpr properties that the fields on a page have.
I created a global variable "TxtStyleExpr" of type Text with no length.
On the page, I put that variable, "TxtStyleExpr" in the property "StyleExpr" leaving "Style" on <none>.
Then in code I use that text variable in the OnAfterGetRecord:
TxtStyleExpr := 'Standard'; // Default
IF (BooOrderExpired) THEN
TxtStyleExpr := 'Unfavorable'; // Bold Red
IF (BooOrder5DayNotice) THEN
TxtStyleExpr := 'Ambiguous'; // Orange
You can only use the styles that are defined by Microsoft.
The URL that DenSter provided has a list that defines them.
I have only tried it in the windows client and it works there.
As DenSter already mentioned it has to do with the Style and StyleExpr properties that the fields on a page have.
I created a global variable "TxtStyleExpr" of type Text with no length.
On the page, I put that variable, "TxtStyleExpr" in the property "StyleExpr" leaving "Style" on <none>.
Then in code I use that text variable in the OnAfterGetRecord:
TxtStyleExpr := 'Standard'; // Default
IF (BooOrderExpired) THEN
TxtStyleExpr := 'Unfavorable'; // Bold Red
IF (BooOrder5DayNotice) THEN
TxtStyleExpr := 'Ambiguous'; // Orange
You can only use the styles that are defined by Microsoft.
The URL that DenSter provided has a list that defines them.
I have used your example, it did not go well, the font color has not changed, this is the code I have written
trigger OnAfterGetRecord();
begin
MyStyleExpr := 'Standard';
if ("Document No." = 'FVR00043') then
MyStyleExpr := 'Ambiguous';
end;
var
MyStyleExpr: Text;
Did you set the StyleExpr property to your MyStyleExpr variable? I set it at a field level. In the screenshot you see that only No and Name are formatted, those are the fields that I set the StyleExpr property.
Answers
Maybe this will get you started:
https://docs.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/properties/devenv-style-property
RIS Plus, LLC
As DenSter already mentioned it has to do with the Style and StyleExpr properties that the fields on a page have.
I created a global variable "TxtStyleExpr" of type Text with no length.
On the page, I put that variable, "TxtStyleExpr" in the property "StyleExpr" leaving "Style" on <none>.
Then in code I use that text variable in the OnAfterGetRecord:
You can only use the styles that are defined by Microsoft.
The URL that DenSter provided has a list that defines them.
I have used your example, it did not go well, the font color has not changed, this is the code I have written
Can you tell me what I need to make it work well?
Did you set the StyleExpr property to your MyStyleExpr variable? I set it at a field level. In the screenshot you see that only No and Name are formatted, those are the fields that I set the StyleExpr property.
RIS Plus, LLC
I added the property to the field and it worked, I consider that was what was missing. I did it this way, could you tell me if it is the right way?
RIS Plus, LLC