Change language in Codeunit

Peter_PardonPeter_Pardon Member Posts: 16
Hello,

I have a question regariding language in codeunits.

I have a codeunit where I have defined a text constant translated in 3 languages.

In this codunit i add a new purchase line. The description must be filled in with this text constant. But i want that the language of this text constant is dependent of the language in my purchase header and not of my current language i am working with.

Is there anybody who knows trick to solve this?

thanks in advance

Peter

Comments

  • Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    You can try this:
    intCurrentLanguage := GLOBALLANGUAGE;
    GLOBALLANGUAGE := recLanguage.GetLanguageID(recPurchHeader."Language Code");
    recPurchLine.Description := Text50000;
    GLOBALLANGUAGE := intCurrentLanguage;
    
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • krikikriki Member, Moderator Posts: 9,110
    The problem with changing the GLOBALLANGUAGE, is that the user will see Navision Flashing because it changes language.
    It is better to put the text constant in another object and use a function to get the value. In this function, you can change the language of ONLY the object. This will avoid that you see Navision change languages.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • Peter_PardonPeter_Pardon Member Posts: 16
    It works.

    Many thanks Luc
  • Peter_PardonPeter_Pardon Member Posts: 16
    It Flashes a bit but not so much that it is interfering.

    Thanks
  • NavStudentNavStudent Member Posts: 399
    i'm curious if this will work in 5.1
    my 2 cents
Sign In or Register to comment.