web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

How to make Subgrid & HTML webresource readonly depending upon record field value

(0) ShareShare
ReportReport
Posted on by

Hi All,

Requirement is make CRM Custom Entity form readonly when a field value meets a condition, Is there any way to make Subgrid readonly? Also I want to make HTML webresource readonly.

Please share your thoughts

Thanks,

Shaik

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    M I Mostafa Profile Picture
    4,257 on at

    Hi Shaikshavali,

    You can use business rules to make a field read only when you change a field value. You can use a business rule to lock all fields on the form or you can use JavaScript.

    If you use Business Rule, then follow this post:

    www.microsoft.com/.../create-business-rules-and-recommendations-to-apply-logic-in-a-form.aspx

    However, if you want to do it via JavaScript, it might be quicker and short (although it is a script not configuration in this case). The code could be something like this:

    Xrm.Page.data.entity.attributes.forEach(function (attribute, index) {    

       var control = Xrm.Page.getControl(attribute.getName());

       if (control) {

           control.setDisabled(true)

       }

    });

    Finally, to make a web resource read only, you have to handle this from within the web resource. So every time the web resource loads, it checks the field value and make all its field read-only.

    Hope this helps! Please mark as verified answer if you found this response helpful.

  • Gopalan Bhuvanesh Profile Picture
    11,401 on at

    Hi

    You want to make the form read only.

    Editing through workflow, plugin, JavaScript is allowed for the record if the field condition meets?

  • Shaik Profile Picture
    on at

    Yes we are fine with customization's.

    FYI: We have couple of subgrids, HTML webresources on the form. I was able to make other fields of form readonly using Business rules but not for subgrids and HTML webresources

  • Verified answer
    Nithya Gopinath Profile Picture
    17,078 on at

    Hi,

    You could write javascript function and register the function on change of the field value.

    function DisableHTMLWebresouceAndSubgridControl() {
        //Get the field value
        var fieldValue = Xrm.Page.getAttribute("attributename").getValue();
    
        //Get HTML web resource control
        var webRefCtrl = Xrm.Page.getControl("WebResource_WebResourceName").getObject();
    
        //Get Subgrid control
        var subGridCtrl = window.parent.document.getElementById("SubgridName_span");
    
        //If web resource and subgrid are not loaded yet, then call same function after some time.
        if ((webRefCtrl == null) || (subGridCtrl == null)) {
            setTimeout(DisableHTMLWebresouceAndSubgridControl, 1000)
            return;
        }
    
        //Check the required condition
        if (fieldValue == null) {
            //web resource HTML document
            var htmlDoc = webRefCtrl.contentDocument;
    
            //get list of controls by tag name
            var ctrlList = htmlDoc.getElementsByTagName('select');
    
            //get list of controls by Id
            var ctrlById = doc.getElementById('textCtrl');
    
            // disable control in HTML web resource.
            ctrlList[0].disabled = true;
    
            // disable the subgrid control
            subGridCtrl.disabled = true;
        }
    }

    Hope this helps.

  • Verified answer
    Shaik Profile Picture
    on at

    Thanks all for your responses. Depending upon attribute value, Sub-grid can be disabled using Ribbon workbench

    ribbonworkbench.uservoice.com/.../489288-show-or-hide-the-add-new-button-on-form-sub-grid

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans