locked
How to disable iframe (HTML) on an entity form in CRM 2015? RRS feed

  • Question

  • Hi All,

    Can any one please help me achieving the solution for the below scenario:

    I have a HTML web resource for a mutlicheck (tuneMulticheckbox) box in an entity form. I need to enable/disable based on a drop down value selected in the form. How can I disable the web resource and the best way to do it?

    Thanks & Regards,

    Sri

    Monday, September 21, 2015 9:42 AM

Answers

  • Hi All,

    I was able to achieve with below code:

    //disable a multicheckbox control
    function DisableMultiCheckBoxControl() {
        var customHtml = Xrm.Page.ui.controls.get("WebResourceName");
        var destination = customHtml.getObject().contentWindow.document;
        if (destination) {
            var customControl = $('.container', destination);
            var attr = $(customControl).attr('disabled');
            if (!attr) {
                customControl.attr('disabled', 'true');
                setTimeout(DisableMultiCheckBoxControl, 1000)
                return;
            }
        }
    }

    //enable a multicheckbox control
    function EnableMultiCheckBoxControl() {
        var customHtml = Xrm.Page.ui.controls.get("WebResourceName");
        var destination = customHtml.getObject().contentWindow.document;
        if (destination) {
            var customControl = $('.container', destination);
            var attr = $(customControl).attr('disabled');
            if (attr) {
                customControl.removeAttr('disabled'); // Enable
                setTimeout(EnableMultiCheckBoxControl, 1000)
                return;
            }
        }
    }

    Thanks,

    Sri

    • Marked as answer by K_Srinivas Wednesday, September 23, 2015 12:55 AM
    Wednesday, September 23, 2015 12:54 AM

All replies

  • Hello,

    The only way is to  extend your existing control with code that will handle onchange event of your form-present field. Following article could help you with it - https://community.dynamics.com/crm/b/hardworkdays/archive/2015/02/28/howto-html-js-webresources


    Dynamics CRM MVP
    My blog

    Monday, September 21, 2015 10:54 AM
    Moderator
  • Hi All,

    I could achieve it with the below code:

    //disable a multicheckbox control

    function DisableMultiCheckBoxControl() {
        var customHtml = Xrm.Page.ui.controls.get("WebResourceName");
        var destination = customHtml.getObject().contentWindow.document;
        if (destination) {
            var customControl = $('.container', destination);
            var attr = $(customControl).attr('disabled');
            if (!attr) {
                customControl.attr('disabled', 'true');
                setTimeout(DisableMultiCheckBoxControl, 1000)
                return;
            }
        }
    }

    //enable a multicheckbox control

    function EnableMultiCheckBoxControl() {
        var customHtml = Xrm.Page.ui.controls.get("WebResourceName");
        var destination = customHtml.getObject().contentWindow.document;
        if (destination) {
            var customControl = $('.container', destination);
            var attr = $(customControl).attr('disabled');
            if (attr) {
                customControl.removeAttr('disabled'); // Enable
                setTimeout(EnableMultiCheckBoxControl, 1000)
                return;
            }
        }
    }

    Thanks,

    Sri

    Tuesday, September 22, 2015 6:05 AM
  • Hi All,

    I was able to achieve with below code:

    //disable a multicheckbox control
    function DisableMultiCheckBoxControl() {
        var customHtml = Xrm.Page.ui.controls.get("WebResourceName");
        var destination = customHtml.getObject().contentWindow.document;
        if (destination) {
            var customControl = $('.container', destination);
            var attr = $(customControl).attr('disabled');
            if (!attr) {
                customControl.attr('disabled', 'true');
                setTimeout(DisableMultiCheckBoxControl, 1000)
                return;
            }
        }
    }

    //enable a multicheckbox control
    function EnableMultiCheckBoxControl() {
        var customHtml = Xrm.Page.ui.controls.get("WebResourceName");
        var destination = customHtml.getObject().contentWindow.document;
        if (destination) {
            var customControl = $('.container', destination);
            var attr = $(customControl).attr('disabled');
            if (attr) {
                customControl.removeAttr('disabled'); // Enable
                setTimeout(EnableMultiCheckBoxControl, 1000)
                return;
            }
        }
    }

    Thanks,

    Sri

    • Marked as answer by K_Srinivas Wednesday, September 23, 2015 12:55 AM
    Wednesday, September 23, 2015 12:54 AM