Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Answered

How to Hide or Show subgrid button based on the parent form type.

Posted on by 435

Hello friends,

                  We have requirement to hide or show the subgrid "+" button on the basis of parent form.

For ex : Suppose we have A and B entity. A entity is a parent entity and B is a child entity . A entity have subgrid of B entity and sugrid will have  "+" button.

                 Now if the A entity becomes read only , I want to hide that  "+" button else I want to show that "+"  button.Does anybody have idea about the same? How can we achieve this functionality?

Please help ASAP. It's urgent!!!!

  • Royal King Profile Picture
    Royal King 27,686 on at
    RE: How to Hide or Show subgrid button based on the parent form type.

    javascript going to run in the context of parent entity not in the context of child entity.So in the javascript just check for the form type  Xrm.Page.ui.getFormType() == 3 //read-only

    if it's read-only return true otherwise false.

  • Verified answer
    Prashant Wani Profile Picture
    Prashant Wani 435 on at
    RE: How to Hide or Show subgrid button based on the parent form type.

    How would I check the "Parent Form Type" in the given javascript on child entity?

  • Verified answer
    Mahadeo Matre Profile Picture
    Mahadeo Matre 17,021 on at
    RE: How to Hide or Show subgrid button based on the parent form type.

    You can do this by enable rule for + button.

    Here are steps

    1. Open your customization in ribbon workbench.

    2. Click on Entity B subgrid navigation

    3. Select + new Button and right click and select customize command. 

    4. Then add Enable Rule 

    5. In the enable rule use Client JavaScript function. 

    6. In the client JavaScript function add following code. 

    DisableSubGridNewButton: function () {	
            if (Check Your required condition) {
                return false;
            }
            else
                return true;       
        },

    Call this function in enable rule

    7. Add enable rule for your +new button command 

    8. Save and publish your customization.. 

    When function return false.. at that time button will be hidden.. 

    If you have Associated view for this entity.. then might be your need to hide Add Existing button also.. 

    Hope this will help.. 

  • Suggested answer
    Royal King Profile Picture
    Royal King 27,686 on at
    RE: How to Hide or Show subgrid button based on the parent form type.

    check the below post that will guide to enable/disable "+" button of the subgrid in the form based value of the parent .

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

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,696 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,490 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans