Below is the New Syntax available to get CRM LoggedIn User Settings in Dynamics 365 V9.X,
var userSettings = Xrm.Utility.getGlobalContext().userSettings;
The userSettings object provides following properties,
Syntax | Type | Description |
userSettings.dateFormattingInfo() | Object | Returns the date formatting information object for the current user.
An object with informatiuon about date formatting such as FirstDayOfWeek, LongDatePattern, MonthDayPattern, TimeSeparator, and so on. |
userSettings.defaultDashboardId | String | Returns the ID of the default dashboard for the current user. |
userSettings.isGuidedHelpEnabled | Boolean | Indicates whether guided help is enabled for the current user.
returns true if enabled; false otherwise. |
userSettings.isHighContrastEnabled | Boolean | Indicates whether high contrast is enabled for the current user.
returns true if enabled; false otherwise. |
userSettings.isRTL | Boolean | Indicates whether the language for the current user is a right-to-left (RTL) language.
returns true if it is RTL; false otherwise. |
userSettings.languageId | Number | Returns the language ID for the current user. |
userSettings.securityRolePrivileges | Array | Returns an array of strings that represent the GUID values of each of the security role privilege that the user is associated with or any teams that the user is associated with.
GUID values of each of the security role privilege. |
userSettings.securityRoles | Array | Returns an array of strings that represent the GUID values of each of the security role that the user is associated with or any teams that the user is associated with.
GUID values of each of the security role. For example: [“0d3dd20a-17a6-e711-a94e-000d3a1a7a9b”, “ff42d20a-17a6-e711-a94e-000d3a1a7a9b”]. |
userSettings.transactionCurrencyId | String | Returns the transaction currency ID for the current user. |
userSettings.userId | String | Returns the GUID of the SystemUser.Id value for the current user.
The ID of the user. For example: “{75B5BA27-FD41-4D45-8E3A-C8446C95F0CC}” |
userSettings.userName | String | Name of the current user. |
userSettings.getTimeZoneOffsetMinutes() | Number | Returns the difference in minutes between the local time and Coordinated Universal Time (UTC).
Time zone offset in minutes. |
Example: Below function configured on Account Page Load.
function GetUserSettingsDetails() { var outputText = "User Settings Details\n--------------------------------------------\n"; var userSettings = Xrm.Utility.getGlobalContext().userSettings; outputText += "Date Formatting Info : " + userSettings.dateFormattingInfo() + "\n"; outputText += "Is Guided Help Enabled: " + userSettings.isGuidedHelpEnabled + "\n"; outputText += "Is High Contrast Enabled : " + userSettings.isHighContrastEnabled + "\n"; outputText += "RTL (Right To Left) : " + userSettings.isRTL + "\n"; outputText += "Language Id : " + userSettings.languageId + "\n"; outputText += "Security Roles : " + userSettings.securityRoles + "\n"; outputText += "Transaction Currency Id : " + userSettings.transactionCurrencyId + "\n"; outputText += "User Guid : " + userSettings.userId + "\n"; outputText += "User Name : " + userSettings.userName + "\n"; outputText += "Time Zone Offset Minutes : " + userSettings.getTimeZoneOffsetMinutes() + "\n"; Xrm.Utility.alertDialog(outputText, null); }
Output:


Hope you learned a new thing today :):):)