Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Answered

How to hide related subgrid button on readonly

(0) ShareShare
ReportReport
Posted on by 90

Hello,

How can I hide the add new button on related subgrid when the form is readOnly.

I have tried the following but it does not seem to work for me

pastedimage1622912396851v1.png

Thanks in advance

  • Ainsley Profile Picture
    Ainsley 90 on at
    RE: How to hide related subgrid button on readonly

    thanks!

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to hide related subgrid button on readonly

    Hi Ainsley,

    You can do this by adding enable rule for + or Add New Button.

    1. Open Child record customization in Ribbon workbench
    2. Select Entity so that we will able to modify command definition.
    3. In Sub Gird, select + Add New {0} Button, right click and select Customize Command.
    4.  Add New Enable Rule
    5. For Enable Rule.. Add steps, and select Custom Rule.

    Js code:

    function DisableSubGridNewButton() {

        if (Xrm.Page.ui.getFormType() == 3) // Read Only

            return false;

        else

            return true;

    }

    Maybe you can refer following link:

    (+) Hide SubGrid '+' / New Button button based on Parent status - Microsoft Dynamics CRM Community

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to hide related subgrid button on readonly

    Hi Ainsley,

    You can do this by adding enable rule for + or Add New Button.

    1. Open Child record customization in Ribbon workbench
    2. Select Entity so that we will able to modify command definition.
    3. In Sub Gird, select + Add New {0} Button, right click and select Customize Command.
    4.  Add New Enable Rule
    5. For Enable Rule.. Add steps, and select Custom Rule.

    Js code:

    function DisableSubGridNewButton() {

        if (Xrm.Page.ui.getFormType() == 3) // Read Only

            return false;

        else

            return true;

    }

    Maybe you can refer following link:

    (+) Hide SubGrid '+' / New Button button based on Parent status - Microsoft Dynamics CRM Community

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Ainsley Profile Picture
    Ainsley 90 on at
    RE: How to hide related subgrid button on readonly

    nope didnt work for me, im not sure if the subgrid is aware of the parent.context

  • Suggested answer
    Wahaj Rashid Profile Picture
    Wahaj Rashid 11,319 on at
    RE: How to hide related subgrid button on readonly

    Hi,

    Thank you for your query.

    Use Enable Rule (instead of Display Rule).

    Also, here is a related post (it does something else, but you will get some idea):

    Unlocking “add new” on the subgrids for read-only records | It Ain't Boring (itaintboring.com)

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,433 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans