Hide child records sub grid + or Add New button
Some time we need to hide '+' button or Add New button for child record grid..
You can do this by adding enable rule for + or Add New Button.
1. Open Child record customization in Ribbon workbench
2. Select Entity so that we will able to modify command definition.
3. In Sub Gird, select + Add New {0} Button, right click and select Customize Command
4. Add New Enable Rule
5. For Enable Rule.. Add steps, and select Custom JavaScript Rule
7. Add this enable rule to button Command
8. Save and Publish Customization.
Some time we need to hide '+' button or Add New button for child record grid..
You can do this by adding enable rule for + or Add New Button.
1. Open Child record customization in Ribbon workbench
2. Select Entity so that we will able to modify command definition.
3. In Sub Gird, select + Add New {0} Button, right click and select Customize Command
4. Add New Enable Rule
5. For Enable Rule.. Add steps, and select Custom JavaScript Rule
6. Set Custom rule properties as
Default : true
Function Name: DisableSubGridNewButton
Invert Result : False
Library: JavaScript web resource where you added DisableSubGridNewButton function
Parameters : None.
JavaScript DisableSubGridNewButton Function
-- When Form is ready only then hide +new or Add new Button for child records.
function DisableSubGridNewButton() {
if (Xrm.Page.ui.getFormType() == 3) // Read Only
return false;
else
return true;
}
-- based on Some values on Form
function DisableSubGridNewButton() {
var IsMarried = Xrm.Page.getAttribute('new_status').getValue();
if (IsMarried == 70000001) //un
marriged
return false; // Hide button
else
return true; //Show button
}
7. Add this enable rule to button Command
8. Save and Publish Customization.
Hi,
ReplyDeleteI tried this method and yet I was unable to Hide the button in the sub-grid. When I published the Workbench and go back to the CRM page, I yet see the "+" button in the sub-grid form. Is there anything you could suggest me?
I will suggest to add Debugger in javascript function and try debugging your code..
ReplyDeleteAlso Try clearing browser cache.. sometimes browser cache is giving problem to reflect items.
Hello,
ReplyDeleteReally helpful link. I have a question though, what events do refresh the evaluation of such rules?
Thanks,
Jorge.
I want to validate user roles in JS before hiding. This i achieved with JS on form and editable grids, but it is not working on Ribbon fields(add new and add existing). Can you help me with it. Thanks in advance
ReplyDeleteSimply want to say your article is as amazing. The clarity in your post is simply great and i can assume you’re an expert on this subject. Well with your permission let me to grab your RSS feed to keep up to date with forthcoming post. Thanks a million and please continue the enjoyable work.
ReplyDeletewhat's hot on ebay
This comment has been removed by the author.
ReplyDelete