How to get the Current Organization Settings using JavaScript in Dynamics 365 V9.X?

Below is the New Syntax available to get Current Organization Settings in Dynamics 365 V9.X,

var organizationSettings = Xrm.Utility.getGlobalContext().organizationSettings;

The organizationSettings object provides following propertiSELRES_9e827887-e80e-4701-803c-ed9d51c22944SELRES_cb9358a4-783e-469a-80a0-29a2ac8ee3f7SELRES_b890e71f-c06b-4ce9-a24a-a17bfb5db450SELRES_a4fc1d9c-9f44-47c2-83a9-985e52e8f7a3SELRES_e24bf811-7ea2-4a3b-944f-f6e83797109aSELRES_7c5468be-ec29-4be3-839e-54997f6da776SELRES_17d15528-4b44-4ddb-b280-8a186a56999fSELRES_2528afac-6b72-49d3-836d-6498b40d5dc6SELRES_2528afac-6b72-49d3-836d-6498b40d5dc6SELRES_17d15528-4b44-4ddb-b280-8a186a56999fSELRES_7c5468be-ec29-4be3-839e-54997f6da776SELRES_e24bf811-7ea2-4a3b-944f-f6e83797109aSELRES_a4fc1d9c-9f44-47c2-83a9-985e52e8f7a3SELRES_b890e71f-c06b-4ce9-a24a-a17bfb5db450SELRES_cb9358a4-783e-469a-80a0-29a2ac8ee3f7SELRES_9e827887-e80e-4701-803c-ed9d51c22944es.

Syntax Type Description
organizationSettings.attributes Object An object with attributes and their values.
organizationSettings.baseCurrencyId String ID of the base currency.
organizationSettings.defaultCountryCode String Default country/region code for phone numbers.
organizationSettings.isAutoSaveEnabled Boolean true if enabled; false otherwise.
organizationSettings.languageId Number Preferred Language ID. For example: 1033 for English
organizationSettings.organizationId String Id of the current organization.
organizationSettings.uniqueName String Unique name of the current organization.
organizationSettings.useSkypeProtocol Boolean true if Skype protocol is used; false otherwise.

Example: Below function configured in Account Page Load.

function GetOrganizationDetails() {
 var outputText = "Organization Details\n--------------------------------------------\n";
 var organizationSettings = Xrm.Utility.getGlobalContext().organizationSettings;

outputText += "Unique Name : " + organizationSettings.uniqueName +"\n";
 outputText += "Id : " + organizationSettings.organizationId + "\n";
 outputText += "Language Id : " + organizationSettings.languageId + "\n";
 outputText += "Base Currency Id : " + organizationSettings.baseCurrencyId + "\n";
 outputText += "Default Country Code : " + organizationSettings.defaultCountryCode + "\n";
 outputText += "Is Auto Save Enabled : " + organizationSettings.isAutoSaveEnabled + "\n";
 outputText += "Use Skype Protocol : " + organizationSettings.useSkypeProtocol + "\n";
 outputText += "Attributes : " + organizationSettings.attributes;

Xrm.Utility.alertDialog(outputText, null); 


Organization Details
Current Organization Settings
Organization Details JS Debug
Debug Mode

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


How to use Barcode scanner feature in Dynamics 365 for Phones App using Javascript?

Invokes the device camera to scan the barcode information, such as a product number.


Xrm.Device.getBarcodeValue().then(successCallback, errorCallback);


Parameter Name Type Required Description
successCallback Function Yes A function to call when the barcode value is returned as a String.
errorCallback Function Yes A function to call when the operation fails. An error object with the message property (String) will be passed that describes the error details.

Return Value: On success, returns a string containing the scanned barcode value.

Note: This method is supported only for the mobile clients.

Example: Created a Scan Barcode button on Account Form and configured the below function on OnClick of the button.

function GetBarcodeValue() {
 function success(result) {
 Xrm.Navigation.openAlertDialog({ text: "Barcode value: " + result });
 function (error) {
 Xrm.Navigation.openAlertDialog({ text: error.message });


1.Open Dynamics 365 for Phones App in Mobile or Tablet,

2.Navigate to Accounts and open any Account record and Tap on commands (…).

3.Tap on Scan Barcode.

4.Mobile inbuilt Barcode Scanner app will be opened. Place a Bar Code and scan for it.

5.Once the App identifies the Barcode correctly, it will capture the Barcode Value.

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


How to use Progress Indicator in Dynamics 365 CRM Online V9.X?

1. Show Progress Indicator:

It Displays a progress dialog with the specified message.

Any subsequent call to this method will update the displayed message in the existing progress dialog with the message specified in the latest method call.


The progress dialog blocks the execution until it is closed using the closeProgressIndicator method. So, you must use this method with caution.




Name Type Required Description
Message String Yes The message to be displayed in the progress dialog.

2. Close Progress Indicator:

It Closes a progress dialog box.

If no progress dialog is displayed currently, this method will do nothing. You can display a progress dialog using the showProgressIndicator method.



Example: Used the below code and configured ShowProgressIndicator() in Account Onload.

function ShowProgressIndicator() {
 Xrm.Utility.showProgressIndicator("Show Progress Indicator Demo..........................");
 setTimeout('HideProgressIndicator()', 5000);

function HideProgressIndicator() {

Output: Open any Existing Account Record, Progress Indicator Text is shown and after 5 Seconds, it will be disappeared.

Show Progress Indicator

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

Show Ribbon Buttons Only in Mobile Or Tablets in CRM

Configure the below Enable Rule for the required ribbon buttons to show Only in Mobile/ Tablets and not in CRM Web.

Show Or Hide Ribbon Buttons in Mobile or Tablets

Use the below function,

function ShowOrHideDeviceButtons() {
 var showOrHideFlag = false;
 // Form Factor = 2 - Tablet
 // Form Factor = 3 - Phone
 if (Xrm.Page.context.client.getClient() == "Mobile" && (Xrm.Page.context.client.getFormFactor() == 2 || Xrm.Page.context.client.getFormFactor() == 3)) {
 // Add code that should only run in CRM for phones here
 showOrHideFlag = true;
 return showOrHideFlag;


Dynamics 365 for phones App View: Highlighted ribbon buttons can be seen only in Mobile/ Tablet.

Show Or Hide Ribbon Buttons in Mobile or Tablets in CRM App

CRM Web View: Buttons are not displayed in CRM Web View.

Show Or Hide Ribbon Buttons in Mobile or Tablets in CRM Web

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


How to delete a record in Dynamics 365 Online V 9.X using JavaScript WebAPI?

Below is the latest Syntax available to delete a record in Dynamics 365 Online V9.X using JavaScript,


Xrm.WebApi.deleteRecord(entityLogicalName, id).then(successCallback, errorCallback);


Name Type Required Description
entityLogicalName String Yes The entity logical name of the record you want to delete. For example: “account”.
id String Yes GUID of the entity record you want to delete.
successCallback Function No A function to call when a record is deleted. An object with the following properties will be passed to identify the deleted record:

·        entityType: String. The entity type of the record.·        id: String. GUID of the record.

·        name: String. Name of the record.

errorCallback Function No A function to call when the operation fails.

Return Value:
On success, returns a promise object containing the attributes specified earlier in the description of the successCallback parameter.

Create a new Javascript Webresource (new_Account.js) and copy paste the below code in it and call it on OnLoad of the Account Form.

After that, open an existing Account record.

function DeleteRecord() {
 // Delete Account record
 Xrm.WebApi.deleteRecord("account", "9C36DC38-79E9-E711-A95E-000D3AF27CC8").then(
 function success(result) {
 // Perform operations on record deletion
 Xrm.Utility.alertDialog("Account deleted", null);
 function (error) {
 // Handle error conditions
 Xrm.Utility.alertDialog(error.message, null);


Dynamics 365 Record Deletion V9.X

Hope you have successfully Deleted an Account record using New Syntax.