Hide Add Button on a Subgrid by Applying Custom JavaScript Rule

By | January 20, 2017

Recently we came across a scenario where we needed to show and hide the subgrid add button on satisfaction of a certain condition. We had to take the help of Ribbon Workbench to achieve the same.

Working:

  1. Install Ribbon workbench in your Dynamics CRM/365.Quick Tip Hide Add button on a sub grid by applying custom java script rule
  2. Create a solution with the entity whose subgrid button you want to customize.Quick Tip Hide Add button on a sub grid by applying custom java script rule
  3. Click on the ‘Ribbon Workbench’ button, and then choose the solution consisting your entity from the options populated.
  4. Select the entity in the ‘Ribbon Workbench’.Quick Tip Hide Add button on a sub grid by applying custom java script rule
  5. Then you need to customize the ‘ADD NEW {0}’ button and ‘ADD EXISTING {0}’ button as shown below.Quick Tip: Hide Add button on a sub grid by applying custom java script rule
  6. Then right click on Enable Rules and Add a new ruleQuick Tip: Hide Add button on a sub grid by applying custom java script rule
  7. A new rule is created as shown in the screenshot.Quick Tip: Hide Add button on a sub grid by applying custom java script rule
  8. Now, add steps where you will attach the JavaScript function.Quick Tip Hide Add button on a sub grid by applying custom java script rule
  9. Then go to the ‘Commands’ sections in the main tab and click on the generated command.Quick Tip Hide Add button on a sub grid by applying custom java script rule
  10. Then add the created enable rule using the lookup button as seen in the below screenshot.Quick Tip Hide Add button on a sub grid by applying custom java script rule
  11. The ‘Is Core’ Value for custom enable rule should be false, and for the remaining it should be true.Quick Tip Hide Add button on a sub grid by applying custom java script rule
  12. The result will be as shown below, no ‘+’ sign is seen for the subgrid.Quick Tip Hide Add button on a sub grid by applying custom java script rule

 

In addition, the button is hidden from the associated view as seen in the below screenshot

Quick Tip Hide Add button on a sub grid by applying custom java script rule

Conclusion:

Thus, one can show and hide the add button in the subgrid, depending on certain condition.

Before you move on the next post, Have  a look at Click2Clone – Copy Dynamics CRM Records in 1 Click!

Leave a Reply