locked
Changing Default Filter in Activity and History Associated View RRS feed

  • Question

  • Quick question that could be a very simple solution for some of you...

    How do you change the default filter in Activity and History Associated view?
    Next 30 days is the default for Activity and
    Last 30 days is the default for History...

    Any idea?

    Thanks in advance!

    Sunday, June 7, 2009 11:33 PM

Answers

  • The stunnware code is good for one or the other but not being much of a jscript'er I had trouble getting his code to work for both at one. I did find this code on the net which worked for me. Apologies for not attributing it, I didn't make note of where I got it from. Please note this is apparently unsupported so may break on upgrade but seems to work fine.

    //Activity scheduledend options

    var ActivityOptions =

    {

      All : "All",

      Overdue :"Overdue",

      Today

     

    :"Today",

      Tomorrow :"Tomorrow",

      Next7Days :"NextXDays;7",

      Next30Days :"NextXDays;30",

      Next90Days

     

    :"NextXDays;90",

      Next6Months :"NextXMonths;6"

    }

     

    //Activity History actualend options

    var

     

    HistoryOptions =

    {

      All : "All",

      Today : "Today",

      Yesterday : "Yesterday",

      Last7Days :

     

    "LastXDays;7",

      Last30Days : "LastXDays;30",

      Last90Days : "LastXDays;90",

      Last6Months :

     

    "LastXMonths;6",

      Last12Months: "LastXMonths;12"

    }

     

    var _loadarea = loadArea;

    loadArea = function(sArea,

     

    sParams, sUrl, bIsvMode)

    {

      //load the iframe

      _loadarea(sArea, sParams, sUrl, bIsvMode);

     

      if(

     

    sArea != "areaActivityHistory" &&

          sArea != "areaActivities" ) return;

     

      //create the iframe object

     

     

     var iframe = document.getElementById(sArea + "Frame");

      //wait until the iframe is fully loaded

     

    ("complete")

      iframe.onreadystatechange = function()

      {

        if( iframe.readyState == "complete")

        {

          var picklist,option;

          //reference to the iframe document

          var iframeDoc =

     

    iframe.contentWindow.document;

          switch(sArea)

          {

            case "areaActivityHistory":

     

     

    picklist = iframeDoc.all.actualend[0];

            /* change to suit your needs */

            option =

     

    HistoryOptions.All;

            break;

            case "areaActivities":

            picklist =

     

    iframeDoc.all.scheduledend[0];

            /* change to suit your needs */

            option =

     

    ActivityOptions.All;

            break;

            default: return;

          }

          picklist.value = option;

     

     

     picklist.FireOnChange();

        }

      }

    }


    Want to hear me talk about all things CRM? Check out my blog http://leontribe.blogspot.com/
    • Proposed as answer by Leon TribeMVP Monday, June 8, 2009 2:31 AM
    • Marked as answer by SPCRMCnst Tuesday, June 9, 2009 2:55 AM
    Monday, June 8, 2009 2:31 AM

All replies

  • Michael at Stunnware blog has a good post about this: http://www.stunnware.com/crm2/topic.aspx?id=JS11
    Monday, June 8, 2009 12:12 AM
    Moderator
  • The stunnware code is good for one or the other but not being much of a jscript'er I had trouble getting his code to work for both at one. I did find this code on the net which worked for me. Apologies for not attributing it, I didn't make note of where I got it from. Please note this is apparently unsupported so may break on upgrade but seems to work fine.

    //Activity scheduledend options

    var ActivityOptions =

    {

      All : "All",

      Overdue :"Overdue",

      Today

     

    :"Today",

      Tomorrow :"Tomorrow",

      Next7Days :"NextXDays;7",

      Next30Days :"NextXDays;30",

      Next90Days

     

    :"NextXDays;90",

      Next6Months :"NextXMonths;6"

    }

     

    //Activity History actualend options

    var

     

    HistoryOptions =

    {

      All : "All",

      Today : "Today",

      Yesterday : "Yesterday",

      Last7Days :

     

    "LastXDays;7",

      Last30Days : "LastXDays;30",

      Last90Days : "LastXDays;90",

      Last6Months :

     

    "LastXMonths;6",

      Last12Months: "LastXMonths;12"

    }

     

    var _loadarea = loadArea;

    loadArea = function(sArea,

     

    sParams, sUrl, bIsvMode)

    {

      //load the iframe

      _loadarea(sArea, sParams, sUrl, bIsvMode);

     

      if(

     

    sArea != "areaActivityHistory" &&

          sArea != "areaActivities" ) return;

     

      //create the iframe object

     

     

     var iframe = document.getElementById(sArea + "Frame");

      //wait until the iframe is fully loaded

     

    ("complete")

      iframe.onreadystatechange = function()

      {

        if( iframe.readyState == "complete")

        {

          var picklist,option;

          //reference to the iframe document

          var iframeDoc =

     

    iframe.contentWindow.document;

          switch(sArea)

          {

            case "areaActivityHistory":

     

     

    picklist = iframeDoc.all.actualend[0];

            /* change to suit your needs */

            option =

     

    HistoryOptions.All;

            break;

            case "areaActivities":

            picklist =

     

    iframeDoc.all.scheduledend[0];

            /* change to suit your needs */

            option =

     

    ActivityOptions.All;

            break;

            default: return;

          }

          picklist.value = option;

     

     

     picklist.FireOnChange();

        }

      }

    }


    Want to hear me talk about all things CRM? Check out my blog http://leontribe.blogspot.com/
    • Proposed as answer by Leon TribeMVP Monday, June 8, 2009 2:31 AM
    • Marked as answer by SPCRMCnst Tuesday, June 9, 2009 2:55 AM
    Monday, June 8, 2009 2:31 AM
  • As a follow-up, I've now googled the code and found where I got it from:


    Kudos to Adi Katz for this one.

    Leon Tribe
    Want to hear me talk about all things CRM? Check out my blog

    Want to hear me talk about all things CRM? Check out my blog http://leontribe.blogspot.com/
    Tuesday, June 9, 2009 3:35 AM
  • Dear Leon,

    Is this a clear solution for this. Also, i that script can work with CRM 2011.

    I saw couple of post that used JScript to accomplish the requirement.

    Also the customization that you are suggesting, support the outlook client and mobile client.

    If you can share your approach that would be Great.

    Thanks.


    Puneet Joshi

    Thursday, March 8, 2012 8:53 PM
  • I'm fairly sure this code will NOT work with 2011 but you do have the ability to specify your own view with in-form grids so that may be of use.

    For v4, the script will work with Outlook but I am not sure about mobile express.

    Leon Tribe

    Want to hear me talk about all things CRM? Check out my blog
    http://leontribe.blogspot.com/
    or hear me tweet http://www.twitter.com/leontribe


    Want to hear me talk about all things CRM? Check out my blog http://leontribe.blogspot.com/ or hear me tweet @leontribe

    • Proposed as answer by Leon TribeMVP Thursday, March 15, 2012 3:46 PM
    Thursday, March 15, 2012 3:46 PM
    • Proposed as answer by Puneet Joshi Tuesday, March 27, 2012 4:46 PM
    Tuesday, March 20, 2012 4:00 PM