Skip to main content

Notifications

Announcements

No record found.

Supply chain | Supply Chain Management, Commerce
Answered

How to change the session language in x++

(0) ShareShare
ReportReport
Posted on by 155

Dear All

Somehow our declared labels for thrown errors are not selected accoring to the POS user language. Is there a possibilty to change the session language?

Thanks

  • Verified answer
    Hanna85 Profile Picture
    Hanna85 155 on at
    RE: How to change the session language in x++

    Hi there

    So I found a way to go around the problem, still it is curious that it dies not take the users (cashier) language:

    xInfo myInfo = new xInfo();
    LanguageId myLang = myInfo.language();

    str text = new Label(myLang).extractString("@Label");

    text = new Label("en-us").extractString("@Label" + subStr(myLang,1,2));


    throw error(strFmt(text,));

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: How to change the session language in x++

    Hi Hanna85,

    Probably RunAs method could solve your issue, but I have a feeling that the language parameter doesn't work properly

    docs.microsoft.com/.../xpp-session-run-time-functions

  • Hanna85 Profile Picture
    Hanna85 155 on at
    RE: How to change the session language in x++

    I‘m sorry for the confusion.

    I‘m throwing the error in the code, the string comes from the label file:

    throw error(error123, var1)

    Error123 is acailable in 3 different languages.

    the cashier on cloud POS sees the mssage, but in the wrong language.

    so i‘d like to override the session language with the users language

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,280 Super User 2024 Season 2 on at
    RE: How to change the session language in x++

    Hi Hanna85,

    Can you elaborate? Is the error coming from POS or is the cashier using Dynamics 365 client? What exactly is 'Label' in the throw error command? Can you share a screenshot with the current error?

  • Hanna85 Profile Picture
    Hanna85 155 on at
    RE: How to change the session language in x++

    Hi there.

    We use different POS Setups.

    To explain the problem:

    the cashier wants to add a new customer, when he clicks safe, some code is running and when a error occurs a error is thrown:

    throw error(Label)

    The error message comes from the Label file. As the code is called by the RetailSystemUser, the language of this user does not represent the language of the cashier.

    I just would like to temporarly overwrite the session language

  • Sergei Minozhenko Profile Picture
    Sergei Minozhenko 23,089 on at
    RE: How to change the session language in x++

    Hi Hanna85,

    Could you, please, explain a bit what kind of POS are you using? Do you mean that only custom labels don't show text in user language or all kinds of labels?

  • Hanna85 Profile Picture
    Hanna85 155 on at
    RE: How to change the session language in x++

    Thanks. But I really just need a quick code line, if possible. As it is just for RetailsServiceUser coming from the POS. There is no need to implement it for every user

  • Suggested answer
    Ramit Paul Profile Picture
    Ramit Paul 22,300 Most Valuable Professional on at
    RE: How to change the session language in x++

    Hi,

    One fantastic function was shared by Andre.

    www.youtube.com/watch

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans