CRM 2016 + JavaScript: Web Resource cannot be reloaded

Since we got upgraded to CRM 2016 from CRM 2015, we faced a strange issue with JavaScript and Web Resource (html).

At some point of time the script goes to reload the html Web Resource with the following code:

var webResource = Xrm.Page.getControl("WebResource_ControlName");

Easiest way to reload the web resource!

But the same code does not work in case of CRM 2016. As the web resource was already loaded when the page was loaded. CRM 2016 treats the same web resource not to be loaded again (may be for better performance!).

After trying numerous ways to solve, following code worked perfectly:

var webResource = Xrm.Page.getControl("WebResource_ControlName");
webResource.setSrc(Xrm.Page.context.getClientUrl() + "/WebResources/new_webResource?data=someValue%26ver%3D" + Math.random());

Here, I had to pass some parameters. What I have done to modify is added another parameter called “ver” (you can have any other parameter name instead of “ver”) and the value will be rendered from Math.random() method. This way the web browser treats each URL as a new request as Math.random() will return random number each time it will be executed.

CRM 2011: Hitting Save Quote does not do anything, record not saved

As described in the subject line, when user hits the Save/Save & Close button, nothing happens. Quote records are not saved, not even a post back happens when hitting save. We checked all different scenarios and nothing worked as Save event was not triggered.

Users/Team were assigned OOB “Sales Person” roles.
Entity: Quote

Give Product entity a full access to the security role and check saving again. It should work.

Get Parent Node from Kendo UI Tree View

Hi Guys!

If you want to get a parent node of the node you are dragging/dropping in Kendo UI Treeview, you need to use .parentNode() method instead of .parent() method. Mostly these methods are mixed up for when to use them. .parent() returns the array which holds this dataItem.

Here is a sample code for how you can get the parent node:

function dropLeftTree(ev) {
    var data = $("#treeview-left").data("kendoTreeView").dataItem(ev.sourceNode);
    var parent = data.parentNode()

CRM 2011, JavaScript: How to add some action after save record?

Hi there!

I recently had a requirement where I had to save the record and open another form once the button is pressed from ribbon.

I added the save JavaScript to the web resource and call it and call other function to open the form. This was not working for me.

Resolution for this:

Add an event on Save action by:; // openAccountForm is another function which opens the form;
function openAccountForm() {

CRM 4.0: Create Dynamic Menu Items

We had a requirements to add Dynamic Menu Items to CRM 4.0 Toolbar. I have followed following blog post by Sonoma Partners for implementing Dynamic Menu Items. I have modified their code with simple JavaScript DOM.

You can follow above mentioned link to create a stub for the implementation and then refer below mentioned code which uses JavaScript DOM and not JQuery to create them.

function createLinksMenu() {

    var links = getCallLinks();
    var dummyElement;

    var ul = document.getElementById("mnuNew_0_CallCustomer");
    var items = ul.getElementsByTagName("li");
    for (var i = 0; i < items.length; ++i) {
        // do something with items[i], which is a <li> element
        if (items[i].innerHTML.indexOf("Dummy") > 0) {
            dummyElement = items[i].cloneNode(true);

    // Loop through all the links 
    //   then clone the dummy node, update it as necessary and append it to the menu
    for (var i = 0; i < links.length; i++) {

        var elem = document.getElementById("mnuNew_0_CallCustomer");
        var newEle = dummyElement.cloneNode(true); = "CallCustomerMenu" + i;
        newEle.className = "ms-crm-MenuItem-Label";
        newEle.tabIndex = -1;
        newEle.action = "callNumber('" + links[i].Url + "');";
        newEle.innerHTML = "<SPAN class='ms-crm-MenuItem-Label'><A class='ms-crm-MenuLink' tabIndex='-1' onclick='return false;' href='javascript:onclick();' target='_self'><SPAN class='ms-crm-MenuItem-Icon'></SPAN><SPAN class='ms-crm-MenuItem-Text' tabIndex='0'>" + links[i].Name + "</SPAN></A></SPAN>";

    // remove dummy node
    items = ul.getElementsByTagName("li");
    for (var i = 0; i < items.length; i++) {

        // do something with items[i], which is a <li> element
        if (items[i].innerHTML.indexOf("Dummy") > 0) {
            items[i].style.display = "none";

Telerik RadMenu: Cancel Postback if the item is the main menu

If you want to cancel the postback event on RadMenu when main menu is clicked, use following client side javascript function for ClientOnClick event.

function RadMenuClientOnClick(sender, args) {
    if (args.get_item().get_index() == 0 && args.get_item()._hasItems == true) {

CRM 2011 + JavaScript: Get Id of the current record

Get the current record’s Id from the following function:;

CRM 2011 Online JavaScript Error: Using IE for CRM 2011 Online through Citrix

Someone was having problems when using CRM 2011 online through Citrix. And it had only just started happening recently. It occurred when we open a form through Queues in Workplace. See the image of the same.


First observation was that the code is failing for a particular form. Tried clearing browser cache, but did not work… And found these errors in IE:

Message: The system cannot find the path specified.
Line: 1
Char: 16007
Code: 0

Message: The system cannot find the path specified.
Line: 1
Char: 37498
Code: 0

Then found similar problem in MSDN. If you look at this link; it has similar problem that we were facing…

It said, “Microsoft couldn’t solve this issue completely. The only solution is to move CRM web site from trusted to local group in Internet settings on users’ workstations.”

The answer in the link stated that “Microsoft support finally found out what was the problem. The LookupMRU file for some reason grows more than 128K. And IE (IE8) has different limitations for local and trusted zones for download file size.”

Don’t know if the problem is totally solved but if you have faced similar problem then try the solution given and let me know.


CRM 2011: Set Due Date to today and Due Time to 08:00 AM by default

Hello everyone…

Recently I was asked a question:
Can we load current date and time (8 AM default) to Due field in activities in Microsoft Dynamics CRM 2011?
I got the solution… yeah!!

For this you need to edit the activity (Task/Phone Call/Fax/Email/etc.) entity and put a JavaScript in OnLoad event of the entity form.

My First try was to access both date and time through HTML DOM with very easy JavaScript code…

document.getElementById("dateInput").value = currentDate;
document.getElementById("timeInput").value = "08:00";

But, it created a problem; when the date field was edited by the user, the time would change to 00:00 by default. I searched many blogs and finally found an attribute called scheduledend which can be accessed through Xrm.Page object and getAttribute() method. Just need to set a JavaScript date and you have the values desired in Due Date and Time fields.

Here is the script I wrote to populate date and time:

var d = new Date();
var date = new Date(d.getFullYear(), d.getMonth(), d.getDate(), 8, 0, 0, 0);

Here is the result when a new activity is created:

Rikin Shah.