12 Oct’15

Dynamics CRMSolutions to Frequent JavaScript Errors in CRM 2015 Update 1

In this Blog we will walk-through how to resolved CRM 2015 update 1 JavaScript Errors. Below is list of common errors.

1. ‘$ is not defined’ or ‘jQuery is not defined’


Description: You will get above error if you have ever used jQuery function in your JavaScript code. In earlier version of the CRM, we can able to access jQuery library directly but with the new form rendering engine it is not possible to access jQuery library.

Resolution: Include jQuery library in your Entity Form Libraries.


2. Behaviour changed for Tab (open/close).

Description:  Please refer below example

Ex. Read state of the Tab (onTabChanged)

Below function will return different result based on Legacy/Turbo form

User ActionLegacy FormTurbo Form
Tab Closecollapsedexpanded
Tab Openexpandedcollapsed

3. Cannot read property ‘getAttribute’ of null (Specific to Product Form)

Steps to reproduced:

  1. Add new product
  2. 3

  3. Navigate to products
  4. 4

  5. Click on ‘View the data that will be sent to Microsoft’



Description: Error is encountered because CRM internally trying to access any fields which is not present of the form. By doing more researched I found that ‘Valid To’ and ‘Valid From’ field is required on the Form (Turbo Form rendering engine).

Resolution: Please follow the below steps

  1. Add ‘Valid To’ and ‘Valid From’ in the form
  2. 7

  3. Hide both the field and lock this field on the form



4. + button is not working for Opportunity Product SubGrid on Opportunity form

Description: Same problem with Quote/Order product SubGrid view.
It is basically product bug in 2015 update 1.

Resolution:  Add custom HTML web resource for + sign and hide exiting one.

Please find below steps to resolved this issue.

  1. Hide exiting SubGrid + sign using Ribbon workbench.
  2. Add HTML web resource for + sign. You can refer below code.
        <meta charset="utf-8" />
            #plusSign {
                float: right;
                margin-top: 18px;
                cursor: pointer;”
        <script type="text/javascript" src="ClientGlobalContext.js.aspx"></script>
            var GridCustomization = GridCustomization || {};
            GridCustomization.data = {};
            GridCustomization.parameterObject = {};
            GridCustomization.openProductForm = function () {
                Xrm.Utility.openEntityForm(GridCustomization.data.EntityLogicalName, null, GridCustomization.parameterObject);
            GridCustomization.onLoad = function () {
                GridCustomization.data = {};
                GridCustomization.parameterObject = {};
                var id = GridCustomization.getQuerystring("id");
                var plusSignAttribute = document.getElementById("plusSign");
                if (plusSign && !id) {
                    plusSign.disabled = true;
                id = id.replace("%7b", "").replace("%7d", "");
                id = id.replace("{", "").replace("}", "");
                var entityNames = GridCustomization.getQuerystring("data");
                var entityLogicalName, entitySchemaName, formToBeOpen;
                if (entityNames) {
                    var tempArray = entityNames.split("%2c");
                    if (tempArray && tempArray.length === 2) {
                        entityLogicalName = tempArray[0].toLowerCase();
                        entitySchemaName = tempArray[0];
                        formToBeOpen = tempArray[1];
                    else {
                        Xrm.Utility.alertDialog("Entity Name is not provided.", null);
                GridCustomization.data = { EntityLogicalName: formToBeOpen };
                ///current record cab be Opportunity/Quote/Order
                var currentRecord = GridCustomization.retrieveRecord(id, entitySchemaName);
                if (currentRecord) {
                    var entityLogicalNameId = entityLogicalName + "id";
                    GridCustomization.parameterObject[entityLogicalName + "id"] = id;
                    GridCustomization.parameterObject["dynad_currencyid"] = currentRecord["TransactionCurrencyId"] ? currentRecord["TransactionCurrencyId"]["Id"] : null;
                    GridCustomization.parameterObject["dynad_currencyidname"] = currentRecord["TransactionCurrencyId"] ? currentRecord["TransactionCurrencyId"]["Name"] : null
                    GridCustomization.parameterObject["transactioncurrencyid"] = currentRecord["TransactionCurrencyId"] ? currentRecord["TransactionCurrencyId"]["Id"] : null;
                    GridCustomization.parameterObject["transactioncurrencyidname"] = currentRecord["TransactionCurrencyId"] ? currentRecord["TransactionCurrencyId"]["Name"] : null;
                    if (currentRecord["OrderNumber"]) {
                        GridCustomization.parameterObject["dynad_ordernumber"] = currentRecord["OrderNumber"];
            GridCustomization.getQuerystring = function (key) {
                var work = key.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
                var regex = new RegExp("[\\?&]" + work + "=([^&#]*)");
                var qs = regex.exec(window.location.href);
                if (qs == null) return null;
                return qs[1];
            GridCustomization.retrieveRecord = function (id, entityName) {
                "use strict";
                var req = new XMLHttpRequest();
                req.open("GET", encodeURI(Xrm.Page.context.getClientUrl() + "/XRMServices/2011/OrganizationData.svc/" + entityName + "Set(guid'" + id + "')"), false);
                req.setRequestHeader("Accept", "application/json");
                req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
                var data = JSON.parse(req.responseText);
                if (data && data.d) {
                    return data.d;
                else {
                    if (data.error) {
                return null;
            GridCustomization.getLookupId = function (lookupObject) {
                if (!lookupObject && !lookupObject.Id) {
                    return null;
                return lookupObject.Id;
    <body onload="GridCustomization.onLoad()">
        <img src="/_imgs/ribbon/NewRecord_16.png" alt="New Line Item" onclick="GridCustomization.openProductForm()" id="plusSign">
  3. Pass parameter to HTML Web Recourse
    Ex. Schema name of opportunity and logical name of opportunity product.
  4. Make sure checkbox for object-type code and unique identifier as parameter is checked.
  5. 9

  6. Register below function onSave event of Opportunity Entity Form to reload HTML web resource for first time when Record is created.
function reloadHTMLResource() {
    if (Xrm.Page.ui.getFormType() === 1) {
        var iInterval = setInterval(function () {
            if (Xrm.Page.data.entity.getId()) {

                //reload PlusSign
                var plusSignControl = Xrm.Page.ui.controls.get("WebResource_SubGridPlusSign");
                if (plusSignControl) {
                        plusSignControl.setSrc(Xrm.Page.context.getClientUrl() + "//WebResources/dynad_SubGridPlusSign?data=Opportunity%2copportunityproduct&id=" + Xrm.Page.data.entity.getId());                }
        }, 1000);

  1. Note: Kindly replace below text with appropriate value
  2. dynad_SubGridPlusSign?data=Opportunity%2copportunityproduct : %2c indicate punctuation mark (,) to split two entity name
  3. WebResource_SubGridPlusSign : name of HTML web resource added on the form.


Written by

Team Member


One thought on “Solutions to Frequent JavaScript Errors in CRM 2015 Update 1”

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.

Want to streamline your business processes?

  • This field is for validation purposes and should be left unchanged.

Recent Articles

  • Managing mailbox through Email Archiving

    20 March’ 2018

    Introduction: Email can fill your Outlook Inbox quickly – new messages, replies, and forwards. Before you know it, yo...

    Read more
  • Workaround to Report.SAVEASPDF in NAV 2018

    20 March’ 2018

    Objective: In NAV 2017 Emailing the PDF by running the report using Report.SAVEASPDF is now not allowed in NAV 2018. Th...

    Read more
  • Dynamics 365 Client Diagnostics

    15 March’ 2018

    Main cause of Performance Issues: Bandwidth and latency are the primary characteristics which affects the performance o...

    Read more
  • Closing Blind Shift in MPOS and CPOS in Dynamics 365 for Retail

    15 March’ 2018

    Manual For closing Blind shift in POS: Blind shifts terminate the currently ongoing shift and when logged in a new shif...

    Read more
  • Persistent Filters in the Power BI Service

    13 March’ 2018

    Introduction: The feature is finally release, and it is power BI has announced general availability of persistent filt...

    Read more