Thursday, March 10, 2011

Hiding Custom ISV.Config Buttons in CRM 4.0

I needed to hide/show my ISV.config buttons (note the ToolTip is the key here):

 <Entity name="new_myentity">  
<ToolBar>
<Button AccessKey="P" Icon="/_imgs/button_approve.ico"
ValidForCreate="1" ValidForUpdate="1"
JavaScript="ApproveApplication();">
<Titles>
<Title LCID="1033" Text="Approve" />
</Titles>
<ToolTips>
<ToolTip LCID="1033" Text="Approve"/>
</ToolTips>
</Button>
</ToolBar>
</Entity>

So I found some sources that led me to this function that I call in the Entity’s OnLoad event:

 // hide ISV buttons that don't apply

function hideISVButton(buttonTitle) {
var comps = document.getElementsByTagName('li');
for (var i = 0; i < comps.length; i++) {
if (comps[i].title == buttonTitle)
{
comps[i].style.display = "none";
break;
}
}
}

***Interesting to note about the ISV.Config JavaScript…it calls a function that is also defined in the Entity’s OnLoad…a much cleaner alternative to real JS in the ISV.Config file:

 ApproveApplication = function() {

// Your function code here

}


1 comment:

Zahid said...

They return if you resize your window.