Home > MS CRM 2011 > MS CRM 2011 Set “FilterOn” Default Value

MS CRM 2011 Set “FilterOn” Default Value


One of our Customer asked to show all the cases under account regardless of case status as support people are new to CRM and they don't know how to see all cases without someone educating them .

After some gooling found solution in one of MS CRM community site

http://social.msdn.microsoft.com/Forums/de/crmgerman/thread/912fef23-a12d-47db-b754-897f48a025e5

Solution: 

1.Create a new web resource Javascript file in CRM and copy paste below code in the file

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);
                               }
                           };
                       }
                   }
               };
       };
   }
}

2. Reference this web resource file in the account form properties .
3.Add Onload event handler  , add Library as newly added javascript and add function name as setView

4. Add parameters based on for which entity you want to change default "Filter on" View 

Eg: ("Service","All","crmGrid_incident_customer_accounts_statecode") //Case
parameter1 ("Service") : Nav Id of related record in case of case the nav id is navService , remove nav from the nav Id
parameter2 ("All"): default combo value that you want to set
parameter3 : Combobox Id.

//setView(‘Activities’, ‘All’, “crmGrid_Account_ActivityPointers_datefilter”);
//setView(“Invoices”, “All”, “crmGrid_invoice_customer_accounts_statecode”)
//setView(“Orders”,”All”,”crmGrid_order_customer_accounts_statecode”)
//setView(“Opps”,”All”,”crmGrid_opportunity_customer_accounts_statecode”) //Opportnity

//setView(“Quotes”,”All”,”crmGrid_quote_customer_accounts_statecode”)

//setView(“Service”,”All”,”crmGrid_incident_customer_accounts_statecode”) //Case

Advertisements
Categories: MS CRM 2011
  1. connel
    January 22, 2013 at 11:08 pm

    This is a really useful modification which was working well up until the Jan 2013 update to CRM Online. Does anyone know why this has stopped working?

  1. December 16, 2012 at 6:53 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: