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

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

How to display error based on CRM user's language option using JavaScript

(0) ShareShare
ReportReport
Posted on by 65

I need to display an error on the CRM form based on the user's language setting. ex: french user - error needs to be displayed in french. How do i get the language(English or French) that the user has set up in the personalization setting in CRM? 

This is where i need to add error message based on the language option

function checkDuplicateTANDForSameOrg (executionContext) {
const formContext = executionContext.getFormContext();

var Entity = "contact";
var Select = "?$select=fullname";
var Filter = "&$filter=contactid eq '3D36A874-49F6-EC11-82E5-002248AE4B85'";

Xrm.WebApi.retrieveMultipleRecords(Entity, Select + Filter).then(
function success(result) {
if (result != null && result.entities.length > 0) {
formContext.ui.clearFormNotification("contactid");
} else{
formContext.ui.setFormNotification("The organization for the selected contact should be same as the organization of the ROD contact.", "ERROR", "contactid");
}

},
function (error) {
console.log(error.message);
}
);

}

I have the same question (0)
  • SivaR Profile Picture
    65 on at
    RE: How to display error based on CRM user's language option using JavaScript

    Thank you, it worked

  • Verified answer
    Guido Preite Profile Picture
    54,084 Moderator on at
    RE: How to display error based on CRM user's language option using JavaScript

    you can get the user language from the userSettings, this is the docs page

    https://docs.microsoft.com/en-us/power-apps/developer/model-driven-apps/clientapi/reference/xrm-utility/getglobalcontext/usersettings

    you will need to do something like

    let languageId = Xrm.Utility.getGlobalContext().userSettings.languageId;

    and you need to check the languageId returned (LCID)

    this page contains some LCID mapping: https://docs.microsoft.com/en-us/previous-versions/office/sharepoint-csom/jj167546(v=office.15)

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 258

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 172

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 116 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans