{"id":4347,"date":"2017-01-20T17:52:53","date_gmt":"2017-01-20T12:22:53","guid":{"rendered":"https:\/\/www.inogic.com\/blog\/?p=4347"},"modified":"2022-07-19T16:16:20","modified_gmt":"2022-07-19T10:46:20","slug":"hide-add-button-on-a-subgrid-by-applying-custom-javascript-rule","status":"publish","type":"post","link":"https:\/\/www.inogic.com\/blog\/2017\/01\/hide-add-button-on-a-subgrid-by-applying-custom-javascript-rule\/","title":{"rendered":"Hide Add Button on a Subgrid by Applying Custom JavaScript Rule"},"content":{"rendered":"<p>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.<\/p>\n<p><strong>Working:<\/strong><\/p>\n<ol>\n<li>Install Ribbon workbench in your Dynamics CRM\/365.<img decoding=\"async\" class=\"aligncenter size-full wp-image-4335\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Quick-Tip-Hide-Add-button-on-a-sub-grid-by-applying-custom-java-script-rule1.jpg\" alt=\"Quick Tip Hide Add button on a sub grid by applying custom java script rule\" width=\"612\" height=\"253\" \/><\/li>\n<li>Create a solution with the entity whose subgrid button you want to customize.<img decoding=\"async\" class=\"aligncenter size-large wp-image-4336\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Quick-Tip-Hide-Add-button-on-a-sub-grid-by-applying-custom-java-script-rule2-1024x688.jpg\" alt=\"Quick Tip Hide Add button on a sub grid by applying custom java script rule\" width=\"665\" height=\"446\" \/><\/li>\n<li>Click on the \u2018Ribbon Workbench\u2019 button, and then choose the solution consisting your entity from the options populated.<\/li>\n<li>Select the entity in the \u2018Ribbon Workbench\u2019.<img decoding=\"async\" class=\"aligncenter size-large wp-image-4337\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Quick-Tip-Hide-Add-button-on-a-sub-grid-by-applying-custom-java-script-rule3-1024x331.jpg\" alt=\"Quick Tip Hide Add button on a sub grid by applying custom java script rule\" width=\"665\" height=\"214\" \/><\/li>\n<li>Then you need to customize the \u2018ADD NEW {0}\u2019 button and \u2018ADD EXISTING {0}\u2019 button as shown below.<img decoding=\"async\" class=\"aligncenter size-large wp-image-4338\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Quick-Tip-Hide-Add-button-on-a-sub-grid-by-applying-custom-java-script-rule4-1024x332.jpg\" alt=\"Quick Tip: Hide Add button on a sub grid by applying custom java script rule\" width=\"665\" height=\"215\" \/><\/li>\n<li>Then right click on Enable Rules and Add a new rule<img decoding=\"async\" class=\"aligncenter size-full wp-image-4339\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Quick-Tip-Hide-Add-button-on-a-sub-grid-by-applying-custom-java-script-rule5.jpg\" alt=\"Quick Tip: Hide Add button on a sub grid by applying custom java script rule\" width=\"396\" height=\"446\" \/><\/li>\n<li>A new rule is created as shown in the screenshot.<img decoding=\"async\" class=\"aligncenter size-full wp-image-4340\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Quick-Tip-Hide-Add-button-on-a-sub-grid-by-applying-custom-java-script-rule6.jpg\" alt=\"Quick Tip: Hide Add button on a sub grid by applying custom java script rule\" width=\"368\" height=\"449\" \/><\/li>\n<li>Now, add steps where you will attach the JavaScript function.<img decoding=\"async\" class=\"aligncenter size-full wp-image-4341\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Quick-Tip-Hide-Add-button-on-a-sub-grid-by-applying-custom-java-script-rule7.jpg\" alt=\"Quick Tip Hide Add button on a sub grid by applying custom java script rule\" width=\"700\" height=\"410\" \/><\/li>\n<li>Then go to the \u2018Commands\u2019 sections in the main tab and click on the generated command.<img decoding=\"async\" class=\"aligncenter size-full wp-image-4342\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Quick-Tip-Hide-Add-button-on-a-sub-grid-by-applying-custom-java-script-rule8.jpg\" alt=\"Quick Tip Hide Add button on a sub grid by applying custom java script rule\" width=\"359\" height=\"334\" \/><\/li>\n<li>Then add the created enable rule using the lookup button as seen in the below screenshot.<img decoding=\"async\" class=\"aligncenter size-large wp-image-4343\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Quick-Tip-Hide-Add-button-on-a-sub-grid-by-applying-custom-java-script-rule9-1024x373.jpg\" alt=\"Quick Tip Hide Add button on a sub grid by applying custom java script rule\" width=\"665\" height=\"242\" \/><\/li>\n<li>The \u2018Is Core\u2019 Value for custom enable rule should be false, and for the remaining it should be true.<img decoding=\"async\" class=\"aligncenter size-full wp-image-4344\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Quick-Tip-Hide-Add-button-on-a-sub-grid-by-applying-custom-java-script-rule10.jpg\" alt=\"Quick Tip Hide Add button on a sub grid by applying custom java script rule\" width=\"697\" height=\"438\" \/><\/li>\n<li>The result will be as shown below, no \u2018+\u2019 sign is seen for the subgrid.<img decoding=\"async\" class=\"aligncenter wp-image-4345\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Quick-Tip-Hide-Add-button-on-a-sub-grid-by-applying-custom-java-script-rule11-1024x91.jpg\" alt=\"Quick Tip Hide Add button on a sub grid by applying custom java script rule\" width=\"688\" height=\"61\" \/><\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>In addition, the button is hidden from the associated view as seen in the below screenshot<\/p>\n<p><img decoding=\"async\" class=\"aligncenter wp-image-4346\" src=\"https:\/\/www.inogic.com\/blog\/wp-content\/uploads\/2017\/01\/Quick-Tip-Hide-Add-button-on-a-sub-grid-by-applying-custom-java-script-rule12.jpg\" alt=\"Quick Tip Hide Add button on a sub grid by applying custom java script rule\" width=\"782\" height=\"131\" \/><\/p>\n<p><strong>Conclusion:<\/strong><\/p>\n<p>Thus, one can show and hide the add button in the subgrid, depending on certain condition.<\/p>\n<p class=\"article-title\"><a href=\"http:\/\/www.inogic.com\/product\/productivity-pack\/click-2-clone-microsoft-dynamics-crm-records\" target=\"_blank\" rel=\"noopener noreferrer\">Before you move on the next post, Have \u00a0a look at Click2Clone &#8211; Copy Dynamics CRM Records in 1 Click!<\/a><\/p>\n<h2 style=\"text-align: left;\"><div class=\"su-heading su-heading-style-default su-heading-align-center\" id=\"\" style=\"font-size:15px;margin-bottom:5px\"><div class=\"su-heading-inner\">70% of global 2000 companies apply gamification to improve productivity and returns!<\/div><\/div><\/h2>\n<p><em><strong><a href=\"https:\/\/bit.ly\/3RD4lYW\" target=\"_blank\" rel=\"noopener noreferrer\">Gamifics365<\/a> <\/strong>\u2013 Spin the magic of games within Microsoft Dynamics 365 CRM to improve user adoption, enhance productivity, and achieve company goals!<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>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: Install Ribbon workbench in your Dynamics CRM\/365. Create a solution with the entity whose subgrid button you want\u2026 <span class=\"read-more\"><a href=\"https:\/\/www.inogic.com\/blog\/2017\/01\/hide-add-button-on-a-subgrid-by-applying-custom-javascript-rule\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":13,"featured_media":4352,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[13,16,19,33,49],"tags":[100,448,1483],"class_list":["post-4347","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-customizations","category-dynamics-365","category-dynamics-crm","category-javascript","category-ribbon-buttons","tag-add-button-on-a-sub-grid","tag-custom-java-script-rule-dynamics-crm","tag-ribbon-workbench-dynamics-crm"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/4347","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/comments?post=4347"}],"version-history":[{"count":0,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/posts\/4347\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media\/4352"}],"wp:attachment":[{"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/media?parent=4347"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/categories?post=4347"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inogic.com\/blog\/wp-json\/wp\/v2\/tags?post=4347"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}