Monday, February 24, 2014

Hide Unwanted Activities from Activities view Dropdown in MSCRM2011/ MSCRM2013 /MSCRM2015 using javascript

Create a JavaScript web resource with following functions.
 
function AttachHideEvent()
{
    document.getElementById("crmGrid_SavedNewQuerySelector").setAttribute('onclick','HideItems();');
 
    $( "#crmGrid_SavedNewQuerySelector" ).mouseout(function() { HideItems(); });
 
}
 
function HideItems()
{
    if(document.getElementById("ViewSelector_fax") !=null)
    {
        //fax
        document.getElementById("ViewSelector_fax").style.visibility = "hidden";
        document.getElementById("ViewSelector_fax").style.height="0px";
        document.getElementById("ViewSelector_fax").style.float="left";
        //Letter
        document.getElementById("ViewSelector_letter").style.visibility = "hidden";
        document.getElementById("ViewSelector_letter").style.height="0px";
        document.getElementById("ViewSelector_letter").style.float="left";
    }
}
 
 
Then add a enable rule to first button on activities homepage ribbon and call this function with default value = true/ function name= AttachHideEvent/ webresource=web resource created.
 
In 2nd function add activities you want to hide from dropdown.