web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Supply chain | Supply Chain Management, Commerce
Answered

How to change the session language in x++

(0) ShareShare
ReportReport
Posted on by 252

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

I have the same question (0)
  • Suggested answer
    Ramit Paul Profile Picture
    22,797 Most Valuable Professional on at

    Hi,

    One fantastic function was shared by Andre.

    www.youtube.com/watch

  • Hanna85 Profile Picture
    252 on at

    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

  • Sergei Minozhenko Profile Picture
    23,093 on at

    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
    252 on at

    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

  • André Arnaud de Calavon Profile Picture
    301,146 Super User 2025 Season 2 on at

    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
    252 on at

    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

  • Sergei Minozhenko Profile Picture
    23,093 on at

    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

  • Suggested answer
    Hanna85 Profile Picture
    252 on at

    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,));

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
Laurens vd Tang Profile Picture

Laurens vd Tang 301 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 120 Super User 2025 Season 2

#3
Siv Sagar Profile Picture

Siv Sagar 105 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans