One of my gripes with the out of the box functionality in CRM is the inability to override the default Associated View filter. For Activities, the default is “Next 30 days”. If a user wants to default to All activities, they need to select the drop down each time. This isn’t as big of a problem as the perception that an activity, or possibly an opportunity, does not exist.
A client recently asked me to find a workaround to default this to All since various users had complained that they couldn’t find a record even though they knew it existed. I found the following post and initially wasn’t very succesful. I made a minor change to the combobox field it was attempting to pull the readystate value from, and success!
The following snippet will set the Activities and Opportunity view to default to All.
if (typeof (Slalom) == "undefined")
{ Slalom = { __namespace: true }; }
//This will establish a more unique namespace for functions in this library. This will reduce the
// potential for functions to be overwritten due to a duplicate name when the library is loaded.
Slalom.Account = {
SetDefaultView: function(viewCombo, viewName, appGrid) {
if (viewCombo.value != viewName) {
viewCombo.value = viewName;
appGrid.RefreshGridView();
}
},
areaOpportunitiesFrame_OnReadyStateChange: function() {
if (this.readyState == "complete") {
var frame = document.frames("areaOppsFrame");
var viewCombo = frame.document.getElementById("crmGrid_opportunity_customer_accounts_statecode");
var appGrid = frame.document.getElementById("AppGridFilterContainer");
if (viewCombo.readyState == "complete") {
Slalom.Account.SetDefaultView(viewCombo, "All", appGrid);
}
else {
viewCombo.onreadystatechange = function() {
if (this.readyState == "complete") {
Slalom.Account.SetDefaultView(this, "All", appGrid);
}
}
}
}
},
areaActivitiesFrame_OnReadyStateChange: function() {
if (this.readyState == "complete") {
var frame = document.frames("areaActivitiesFrame");
var viewCombo = frame.document.getElementById("crmGrid_Opportunity_ActivityPointers_datefilter");
var appGrid = frame.document.getElementById("AppGridFilterContainer");
if (viewCombo.readyState == "complete") {
Slalom.Opportunity.SetDefaultView(viewCombo, "All", appGrid);
}
else {
viewCombo.onreadystatechange = function() {
if (this.readyState == "complete") {
Slalom.Opportunity.SetDefaultView(this, "All", appGrid);
}
}
}
}
},
formOnLoad: function(){
if (document.getElementById('navActivities') != null) {
document.getElementById('navActivities').onclick = function() {
loadArea('areaActivities');
document.frames('areaActivitiesFrame').document.onreadystatechange = Slalom.Account.areaActivitiesFrame_OnReadyStateChange;
}
}
if (document.getElementById('navOpps') != null) {
document.getElementById('navOpps').onclick = function() {
loadArea('areaOpps');
document.frames('areaOppsFrame').document.onreadystatechange = Slalom.Account.areaOpportunitiesFrame_OnReadyStateChange;
}
}
}
}
No related posts.
