GlobalLanguage() must be implemented through the Translation Helper codeunit (AC0005)
Direct use of GlobalLanguage() leads to verbose, error-prone code and often requires manual state management, hardcoded language IDs, or duplicated logic. The Translation Helper codeunit from the Base Application centralizes global language handling by automatically preserving and restoring the previous language, supporting both LanguageId and LanguageCode, and allowing a safe reset to the default application language without hardcoding values such as 1033.
This pattern ensures that language switches are always properly cleaned up and prevents side effects in multi-language scenarios.
A code fix is available for this diagnostic.
Example
The following code directly manipulates GlobalLanguage:
codeunit 50100 MyCodeunit
{
procedure MyProcedure()
begin
GlobalLanguage(1033); // GlobalLanguage() must be implemented through the "Translation Helper" codeunit from the Base Application. [AC0005]
end;
}
To fix this, use the Translation Helper codeunit:
codeunit 50100 MyCodeunit
{
procedure MyProcedure()
var
TranslationHelper: Codeunit "Translation Helper";
begin
TranslationHelper.SetGlobalLanguageByCode('ENU');
end;
}
See also
- AC0004 - Confirm() must be implemented through the Confirm Management codeunit