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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Hide Subgrid Add New f...
Power Apps
Unanswered

Hide Subgrid Add New for Specific Entities

(0) ShareShare
ReportReport
Posted on by 25

Hi All,

Please can I know a way to hide the 'Add New (+)' subgrid button of an entity ?

I cannot use Ribbon Workbench as the Add New subgrid button is required in some entities but not in some.

Trying the below javascript on the 'Tab Change' event return Null in the window.parent command for the any combinations I have below. 

Any help will be greatly appreciated.

 

function HideAddButtonSubgrid() {

// Get subgrid control
var subGridCtrl = Xrm.Page.getControl("Subgrid_Portfolio_ProgramRisk");  // This returns control

// If subgrid is not loaded yet, then call same function after some time.
if (subGridCtrl == null) {
setTimeout(HideAddButtonSubgrid, 1000);
return;
}

// Get the add button
//var addButton=window.parent.document.getElementById("Subgrid_Portfolio_ProgramRisk"); //Returns Null
// var addButton = window.parent.document.getElementById("Subgrid_Portfolio_ProgramRisk_addImageButtonImage"); //Return Null
var addButton = window.parent.document.getElementById("id-3723");  //Returns Null

// Hide the button
if (addButton != null)
{
addButton.style.display = 'none';  //Doesn't come into this loop 😞
}
}

I have the same question (0)
  • ChrisPiasecki Profile Picture
    6,422 Most Valuable Professional on at

    Hi @RamyaPF,

    You can use the Ribbon Workbench to register an Enable rule for the entity's subgrid add new button. 

    If you want to programmatically control this, you an use a <CustomRule> element and register a JavaScript function from a JavaScript web resource. More information is available below. 

     https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/customize-dev/define-ribbon-enable-rules#custom-rule

    ---
    Please click Accept as Solution if my post answered your question. This will help others find solutions to similar questions. If you like my post and/or find it helpful, please consider giving it a Thumbs Up.

  • EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    Hi @RamyaPF,

    The code pasted is unsupported and wouldn't recommend it. Even though the button is still used for other entities, you can still use the Ribbon Workbench and add some custom display/enable rule logic which checks the current entity and hides it based on the current entity or other any custom logic.

    Here are the quick steps:

    1. Create a new small solution and add only the entity(s) required
    2. Open ribbon workbench and select that solution
    3. Right click on the Add New {0} in the subgrid section and click "Customise Button". The button will then appear in the solution elements pane:
      2020-11-10_16-48-06.png
    4. Right click on the button in the Solution Elements pane and click "Customise Button". It will generate the Command for that button
    5. Select that button's command and add a new Enable Rule
    6. Add a new Custom Rule (JavaScript) step with and point to your JavaScript web resource and function
      1. Add the Primary Control parameter2020-11-10_16-45-16.png
    7. Here's an example of what your function might look like. Note the primaryControl is the formContext

      async function IsButtonVisible(primaryControl) {
         let formContext = primaryControl;

         //some logic
         if (formContext.getAttribute("blabblah").getValue() == null) {
             return false;
         }
         return true;
      }​​

    Hope this helps!

  • RamyaPF Profile Picture
    25 on at

    Thank you @ChrisPiasecki and @EricRegnier .

    @EricRegnier Thank you for pointing out to 'Customise Command' in Ribbon work bench! It opened the flood gate of options!

    I ended up using 'Entity Rule' as below to hide Add new button

    RamyaPF_1-1605024753768.png

     

    This works perfectly 🙂

    But my requirement is little bit complex than that,

    In one of tabs for Entity E1 we have 3 subgrids
    Subgrid 1 of Entity X related to Entity E1 (allow Add + in subgrid)
    Subgrid 2 of Entity X related to Entity E2 (Hide Add new)
    Subgrid 3 of Entity X related to Entity E3 (Hide Add new)

     

    Please can you advise which Display Rule on Entity X in Ribbon Work bench that I can use?

     

  • Verified answer
    EricRegnier Profile Picture
    8,720 Most Valuable Professional on at

    I would have a FormEntityContextRule Rule on the Display Rule to hide based on the parent entity. Hope that works 🙂

  • Sri99 Profile Picture
    2 on at

    Can you please elaborate the solution how to use formentitycontextrule

  • LM19 Profile Picture
    2 on at

    FormEntityContextRule under display rule should do the trick. 

     

    LM19_0-1702647181915.png

     

    LM19_1-1702647206590.png

    This sub grid Add New button will show in all the other table forms and hide on Incident forms.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard