Aug 7, 2013

Microsoft CRM 2011, hide system Save menu

Recently we were asked if it is possible to disable a standard 'Save' menu of Microsoft CRM 2011, since all data on forms is read-only anyway. So, after some searching I've found sample code how to do this. The key was to use "top" property which is containing parent frame which is necessary, since our code (called in "OnLoad" form event) is executing in inner frame. With some modifications this is what finally worked out for me:

var disableSaveMenu = function() {
    // your entities names
    var entities = ["account", "contact" /* add as necessary */];

    var i;
    for(i = 0; i < entities.length; i++) {
        var ent = entities[i];
        var save = top.document.getElementById(ent + "|NoRelationship|Form|Mscrm.Form." + ent + ".MainTab.Save");
        if(save != null) {
            save.style.display = 'none';
            break;
        }
    }
    
    // hide 'File' menu, additional 'Save' is also located there
    var jewel = top.document.getElementById("jewelcontainer");
    if(jewel != null) {
        jewel.style.display = 'none';
    }
};

2 comments:

  1. So, did it work for real? Could you disable the save feature from CRM? I'm so impressed. Thanks for sharing the code. Learned something new here!

    Regards,
    Prasant Saxena

    ReplyDelete
    Replies
    1. Yes, it worked. Not sure if term 'disabled' is appropriate here, but the controls are hidden, so it's nor seen neither possible to click via standard browser interface.

      I guess it's still possible to 'click' them using JavaScript from a debugging console. But if security isn't major concern this solution is fine I guess.

      Delete