Hiding Sub Grid buttons using Ribbon Workbench and JavaScript in Dynamics 365.
Hello Guys,
In my previous blog we have seen how we can hide buttons of the sub grid using Ribbon Workbench customization and we have hidden buttons of employee sub-grid.Today we will see how we do the same thing using JavaScript based on some criteria. But before if you are new to our blog then do follow us to know more about Dynamics and Power Platform. Also if you like our blog then please comment and share this blog with your friends.
Here we will be working with the same example which we have worked in our previous blog.
As you can see here, we have IT department record is opened and it contains employee sub-grid which is having four records. Currently we have made Add Employee button hidden. We will make it visible and will hide based on condition i.e. if total no. of employees is ten then we will hide this button.Which means if sub-grid contains less than 10 records then you can add employee and once it's count will be 10 then we will hide the button.
So first of all we will add one web resource of type JavaScript. Write code as below:
Register this web resource in CRM. We have already registered this web resource as you can see here.
Now open Ribbon Workbench with the solution which contains Employee entity. Select Employee Entity from the drop down. Now right click on Add New(0) button and select customize command.
Now select the command and in the right pane click on Add Enable Rule.
Click on Add step and select custom rule. Configure the rule as below:
Now publish the changes and open IT Department record.
As you can see here we have 9 records which is not satisfying our condition of visibility of the Add new Employee button. Now we will create one more employee in the same department and will refresh the form again.
Here you can see button is hidden now.
Please follow, like and share this blog if you like it.
Hope it helps...
๐๐
ReplyDeleteHelpful๐
ReplyDeleteInteresting blog.
ReplyDeleteThanks for your support.
DeleteFor me, it does not work. i have wrotten test function and returning false, so my grid button should be hiden and that function i have put in enable rule as per blog, please help .
ReplyDeleteit does not work for me, i created test function and returning false and added to enable rule as per blog . Please help
ReplyDelete