Today i got requirement to hide my custom button, i just picked it’s id with the help of IE developer toolbar and used easiest line to hide any control
document.getElementById(‘ISV_New_13_ServiceActivity’).style.display=’none’;
and just publised my entity and started testing it but soon after that i started rubbing my head :-/ as i got JS error, then i test it using alert and found null when tried to get id through document.getElementById.
After some googling i came to know in case of custom button CRM behaves differently, maybe it generate id at run time, so no way to just use simple line to hide button, so i started to searching id of every IL and comparing it with title of my button and it worked
var
ItemList = document.getElementById(“mnuBar1”).rows[0].cells[0].getElementsByTagName(“UL”)[0].getElementsByTagName(“LI”);
for(var i=0; i<ItemList.length-1; i++)
{var str=ItemList[i].id;
if(str.match(‘ServiceActivity’))
{ItemList[i].style.display = “none”;
break;}}
Hope it will help somebody……..