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

Announcements

News and Announcements icon
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 71

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)
  • Verified answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    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)

  • SivaR Profile Picture
    71 on at

    Thank you, it worked

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Nagaraju_Matta Profile Picture

Nagaraju_Matta 102

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 71 Most Valuable Professional

#3
Abhilash Warrier Profile Picture

Abhilash Warrier 66 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans