Not so long ago we were investigating a strange problem with a report. Every time the report was run, the label of one of the fields on a section was not printing what it was supposed to print according to its Caption/CaptionML property, or according to the Caption/CaptionML property of the related field in the table it was linked too. Somehow, something was dynamically changing the label???
After a while we suddenly noticed that the property CaptionClass was filled in, in the properties of the field in the table, and this was the cause of this 'strange behavior.
So, how does this CaptionClass property works?
If the CaptionClass property of a field or a control is defined, the function trigger CaptionClassTranslate (ID 15) in Codeunit 1 (ApplicationManagement) is called by the system every time the field or control is shown. The purpose of this function is to replace the caption, as defined in the design of the field or control, with another string.
2 parameters are passed to this function:
- LANGUAGE
The LANGUAGE parameter is automatically mentioned by the system as is the Windows Language ID of the active language in Navision.
If the active language in Navision is English (United States), LANGUAGE will hold the value 1033. - CAPTIONEXPR
The CAPTIONEXPR parameter holds the content of the CaptionClass property of the field or control.
In a way, the function trigger CaptionClassTranslate (ID 15) is a system trigger:
This standard code analyzes and unravels the CaptionExpr parameter. This parameter has the following syntax:
- CAPTIONEXPR := <CAPTIONAREA>,<CAPTIONREF>
Depending upon the value of the CAPTIONAREA, different procedures are called. Either:
- DimCaptionClassTranslate(Language, CaptionRef)
or
- VATCaptionClassTranslate(Language, CaptionRef)
This is the way the standard functionality in Dynamics NAV deals with the CaptionClass property. Every field or control with a defined CaptionClass has a string in this property with the syntax described earlier.
The following diagram illustrates this sequence:
So, knowing this and with a little bit of imagination, you could extend the code in the CaptionClassTranslate trigger to be able to dynamically translate/change labels in Dynamics NAV.
Comments