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 😞
}
}