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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

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

(0) ShareShare
ReportReport
Posted on by 441

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!!!!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Royal King Profile Picture
    27,686 on at

    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

  • Verified answer
    Mahadeo Matre Profile Picture
    17,021 on at

    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.. 

  • Verified answer
    Prashant Wani Profile Picture
    441 on at

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

  • Royal King Profile Picture
    27,686 on at

    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.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
RichardM Profile Picture

RichardM 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans