Thursday 6 November 2014

Change the "Filter on" to all on the Activity Associated views

When we want to see all activities from an account the default value is "next 30 days".

If you want to change the default value there no easy way to do so. One the things it's change it by JavaScript.

Create a new JavaScript web resource and add this code to it:

 //default the Activities 'Filter on' to 'All'  
 function filterAllActivities() {  
   document.getElementById("navActivities").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);  
     };  
   };  
 }

Add this new JavaScript web resource library to the form properties (from the entity you want exemple: account, case, opportunity, etc), add an event handler in the form "OnLoad" and call the function "filterAllActivities"

Save and publish.

No comments:

Post a Comment