In CRM Dynamics 2015 Online, I have been using the following code as an onload event on the account forms to set the default filter to 'All' for the Open Activities Associated View:
//default the Activities 'Filter on' to 'All' for Account and Contact for rollup 12
function filterAllActivities() {
document.getElementById("nav_Activities").onclick = function () {
Mscrm.Details.loadArea(this, "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";
var evt = document.createEvent("HTMLEvents");
evt.initEvent("change", false, true);
filterOn.dispatchEvent(evt);
};
};
}
This has been working like a charm. However - Yesterday we got the new update to CRM Online 2015, and now when I load my account forms it errors out with this:
TypeError: Unable to set property 'onclick' of undefined or null reference
at filterAllActivities (metacompliance.crm4.dynamics.com/.../new_filteraccountactivities)
at eval code (eval code:1:1)
at RunHandlerInternal (metacompliance.crm4.dynamics.com/.../ClientApiWrapper.aspx:142:1)
at RunHandlers (metacompliance.crm4.dynamics.com/.../ClientApiWrapper.aspx:101:1)
at OnScriptTagLoaded (metacompliance.crm4.dynamics.com/.../ClientApiWrapper.aspx:215:1)
at Anonymous function (metacompliance.crm4.dynamics.com/.../ClientApiWrapper.aspx:186:1)
Obviously I can disable the event and it all works fine - but I really liked the All filter as it suits everything we do. Has anyone been able to get this working in the latest version?
Thanks
Noel