Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Disabling subgrid using javascript in CRM 2016 SP 2

Posted on by Microsoft Employee

Hi i tried to disable subgrid using javascript in CRM 2016 SP 2, unfortunately this javascript below is not working anylonger.

function disableSubgrid(subgridName) {
    document.getElementById(subgridName + "_span").disabled = "true";
}


Do you have any workaround ?

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disabling subgrid using javascript in CRM 2016 SP 2

    Hi srikanth, what is "contentIFrame0" ?

    Updated:

    Just ignore the question above, your code works like a charm. Thanks

  • SrikanthP  Profile Picture
    SrikanthP 45 on at
    RE: Disabling subgrid using javascript in CRM 2016 SP 2

    Yes, I knew it but this is the only way we can prevent the user to perform any action on sub-grid by having him to see the records.  

  • sardar ahmed Profile Picture
    sardar ahmed 520 on at
    RE: Disabling subgrid using javascript in CRM 2016 SP 2

    Hi Srikanth,

    It seems like an unsupported way :)

  • Verified answer
    SrikanthP  Profile Picture
    SrikanthP 45 on at
    RE: Disabling subgrid using javascript in CRM 2016 SP 2

    Hi Fikri,

    Copy the below function into your script file and pass the grid unique name which your want to disable it.

    function disableGrid(gridName) {
        var contentFrame = window.top.document.getElementById("contentIFrame0")
        if (contentFrame) {
            setTimeout(disableGrid.call(null, gridName), 1000);
        } else {
            var grid_span = contentFrame.contentWindow.document.getElementById(gridName + "_span");
            if (grid_span) {
                grid_span.style.pointerEvents = 'none';
            }
        }
    }

    Please mark this as verified answer, if it helps you :).

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Disabling subgrid using javascript in CRM 2016 SP 2

    Hi,

    so what exactly your user want, i thought they want to stop user to create record based on certain value?

    If you are using Dynamics 365, make your subgrid as editable grid and disabled the field you wanted.

    bettercrm.blog/.../disable-columns-in-editable-grid

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disabling subgrid using javascript in CRM 2016 SP 2

    Your suggestion looks like similiar to sardar ahmed suggestion, and i think this not what our user ask.

    Thanks

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disabling subgrid using javascript in CRM 2016 SP 2

    Hi, our users still want to know the records inside the subgrid, i think your suggestion will not match our users request.

    Thanks

  • Suggested answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: Disabling subgrid using javascript in CRM 2016 SP 2

    Hi,

    use ribbon workbench then, changing the display rule and enable rule for create button

    www.develop1.net/.../ribbonworkbench.aspx

    sample concept, in below video I was using entity name as parameter, in your case, pass the result as parameter.

    www.youtube.com/watch

  • sardar ahmed Profile Picture
    sardar ahmed 520 on at
    RE: Disabling subgrid using javascript in CRM 2016 SP 2

    Hi Fikri

    Put it in one section and hide the section.

    Thanks and Regards

    Sardar Ahmed

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Disabling subgrid using javascript in CRM 2016 SP 2

    It's not what we want, we want to disabling subgrid if some field's value meets our condition.

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,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans