Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

making a subgrid readonly on condition

Posted on by 2

I have a table /X/ in CRM with a form that contains a subgrid from related table /Y/.

I would like to make it so that when a condition is met on a record of table /X/ like status = signed, then the subgrid should be locked, ie it should not be possible to add a new relation using the subgrid and it should not be possible to click a record in the subgrid and edit it either by making the record not clickable or having the form on record Y have only readonly fields.

is this possible

  • SH-15050646-0 Profile Picture
    SH-15050646-0 2 on at
    making a subgrid readonly on condition
    Thanks for the suggestion, I thought you solution would work, and it did make the subgrid not clickable but I still need to be able to scroll, change pages and filter on the subgrid and i cant do that with your solution unfortunately.
    Do you have any other suggestions? 
  • Suggested answer
    Dengliang Li Profile Picture
    Dengliang Li Microsoft Employee on at
    making a subgrid readonly on condition
    Hi,
     
    This can be implemented with the following code.

    function onload(executionContext){
        var formContext = executionContext.getFormContext();
     
        //get the Disable Subgrid field value
        var disable_subgrid = formContext.getAttribute("cr147_disablesubgrid").getValue();
        // get the Case Subgird HTML element
        var case_subgrid = parent.parent.window.document.querySelector("div[data-control-name='contactcasessgrid']");
        //Check if the Case Subgrid HTML element is loaded
        if(case_subgrid !== null){
           
            //If the Disable Subgrid field is set to Yes, disable the Case Subgrid.
            if(disable_subgrid === true){
                //set the Case Subgrid not clickable.
                case_subgrid.style.pointerEvents = "none";
                return;
            }
        }else{
            // Wait for some time to check again if the page elements are loaded.
            setTimeout(onload,10,executionContext);
        }
         
    }

     
    I have created a /Disable Subgrid/ field on the form that disables /Case Subgrid/ each time the page loads when the value of this field is set to Yes.
     
     
    If my answer was helpful, please click Like, and if it solved your problem, please mark it as verified to help other community members find more.

    If you have further questions, please feel free to contact me .
     
    Best Regards,
    Dengliang Li
                                                                                                                                                                                           
     
                                                                                                                                                                                                                                                                                                                                              
     
     
     

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans