Default Activities ‘Filter on’ to ‘All’ Dynamics CRM 2011

Paul Nieuwelaar, 18 December 2012

For Dynamics CRM 2011 Rollup 12 users, check out this blog post instead.

In Dynamics CRM 2011, for entities that have Activities such as Account, Contact, and Lead, there is a left-nav related link for Activities and Closed Activities. For Account and Contact, the ‘Activities’ view only shows Open Activities that are due in the next 30 days (Filter on defaults to Next 30 days). Other options include filtering on ‘All’ activities, however this requires a user to change the selection manually each time.

 Default Activities Filter on to All Dynamics CRM 2011

Unfortunately there is no supported way to change this default value automatically, however we can do this using a bit of ‘unsupported’ JavaScript. The following JavaScript should be added to your Account and/or Contact forms OnLoad event. You don’t need to pass it any parameters, just call the ‘filterAllActivities’ function.

//default the Activities 'Filter on' to 'All' for Account and Contact
function
filterAllActivities() {
    document.getElementById("navActivities").onclick = function () {
        loadArea("areaActivities"); 

        document.getElementById("areaActivitiesFrame").onload = function () {
            var entityName = Xrm.Page.data.entity.getEntityName();
            var entity = entityName.charAt(0).toUpperCase() + entityName.substr(1);
            var doc = this.contentWindow.document;
            var filterOn = doc.getElementById("crmGrid_" + entity + "_ActivityPointers_datefilter"); 

            filterOn.value = "All";
            filterOn.FireOnChange();
        };
    };
}

Once this has been saved and published, when you click on the ‘Activities’ link from an Account or Contact, the Activities filter will default to ‘All’ and you will be able to see all of your activities by default. Users can still change the filter to ‘Next 30 days’ for example if required.

Default Activities Filter on to All Dynamics CRM 2011