How to modify default filter in Activities Associated View

In Microsoft CRM 2011, the default view under an Account when you click on the Activities navigation link is to filter the Open Activity Associated View using activities that are due in the Next 30 days. That can be confusing to users of Microsoft CRM - see this kbase article for more details: How Do I See All Activities Under An Account?

The solution to this is to use Javascript to modify the default filter to show All open activities rather than the default of Next 30 days.

Note: this code was authored by this web page: http://niiranen.eu/crm/2012/01/activity-view-default-filter-missing-due-dates-and-how-to-modify-the-filter/ , so full credit goes to them.

The Javascript to use is:

function SetView(type, defaultValue, fieldName)

{

SetDefaultView = function (viewCombo, viewName, appGrid)

{

if (viewCombo.value != viewName)

{

viewCombo.value = viewName;

appGrid.RefreshGridView();

}

}

areaActivitiesFrame_OnReadyStateChange = function ()

{

if (this.readyState == "complete")

{

var frame = document.frames("area" + type + "Frame");

var viewCombo = frame.document.getElementById(fieldName);

var appGrid = frame.document.getElementById("AppGridFilterContainer");

if (viewCombo.readyState == "complete")

{

SetDefaultView(viewCombo, defaultValue, appGrid);

}

else

{

viewCombo.onreadystatechange = function ()

{

if (this.readyState == "complete")

{

SetDefaultView(this, defaultValue, appGrid);

}

}

}

}

}

if (document.getElementById("nav" + type) != null)

{

document.getElementById("nav" + type).onclick = function ()

{

loadArea("area" + type);

document.frames("area" + type + "Frame").document.onreadystatechange =

function ()

{

if (this.readyState == "complete")

{

var frame = document.frames("area" + type + "Frame");

var viewCombo = frame.document.getElementById(fieldName);

var appGrid = frame.document.getElementById("AppGridFilterContainer");

if (viewCombo.readyState == "complete")

{

SetDefaultView(viewCombo, defaultValue, appGrid);

}

else

{

viewCombo.onreadystatechange = function ()

{

if (this.readyState == "complete")

{

SetDefaultView(this, defaultValue, appGrid);

}

}

}

}

}

}

}

}