Home > MSCRM General > Setting Default View for Account Activities???

Setting Default View for Account Activities???

 I have been searching a lot in Newsgroups and forums to find this issue. Issue is “How can I set the default view when I open certain Account Activities”. The default view set is “Next 30 Days” as given in the picture below. I want to set this to “All Activities”. I am looking for any supported and unsupported way of doing this task. I have been told my some MSCRM experts that it is a common issue and I will not be able to set this as this is all set by managed code.Setting Default View for Account Activities???

Anyone doing some tricky JavaScript. Some unsupported way of doing this, please comment. Thanks!

Categories: MSCRM General Tags:
  1. April 23, 2007 at 10:45 pm

    Hi Ayaz,

    I recently wrote an article about it: Client Side Scripting – Changing the default view of related entities


  2. April 23, 2007 at 11:16 pm

    Thanks Michael. Its exactly what i am searching for.

  3. Michael Wahlman
    May 4, 2007 at 6:12 pm

    Where you able to get the code to work?

    I used the code in the article that you Michael Hohne wrote, and while it did change the text displayed in the “filter on” associated history view for accounts, it didnt appear to be changing the results displayed within that view.

    For example, by default the filter is 30 days. After using the code I was able to changing the filter to 90 days, and while it now says 90 days by default, the resulting history displayed for a test account are the same as before (30 days). Now, If I manually change the filter to all, and then back to 90, the correct results will display, but I am not getting those result by default, upon the intitial load when it
    displays that the filter is set to 90 days.

    Am I missing something?

    Michael Wahlman
    MCBMSP – CRM 3.0 Apps / Install & Config

  4. May 4, 2007 at 7:28 pm

    Hi Michael,

    Its working fine at my side. but u need to wait untill form loads completely.



  5. Karla
    May 8, 2007 at 5:03 pm

    I tried to implement the code, but had a couple of issues.
    1. The instruction says to place the code in the “Account’s OnLoad event.” Does this mean the OnLoad event for the Account Form?
    2. I tried putting it in the OnLoad event for the Account Form. I already had some code in there, so I put this code at the end. I kept getting errors (nothing popped up, but the yellow triangle ! symbol appeared in the lower left of the status bar.
    3. If I want to default History and Activities to “All” do I duplicate the code for areaActivities?
    4. I can’t get the instructions for viewing the name of the combo box to work. I get an error. Unfortunately, it just says “An error has occurred. For more information, contact your system administrator.” — Well I am the system administrator, and I can’t find any way (like in CRM 1.2) to turn on “developer mode” so that the errors are helpful.

  6. May 8, 2007 at 6:14 pm

    Hi Karla,

    1) Yes, Account Form onload event.
    2) Properly comment you javascript code. Its working fine at my end. Try to paste it at start of the Onload event javascript. place comments properly to identify your new addition to javascript code like putting BOC – Begin of change and EOC – end of change comments.
    3)well, do the same code in history case but in case of others just leave SetDefaultView function and copy rest of Javascript lines.
    4)try to replance the object id and server name with your server name and object ID for accounts.

    *This code will not work untill the account form loads completely.



  7. May 9, 2007 at 2:43 pm


    I’ve exactely the same problem as Michael Wahlman… The default filter is “All” in my case (correctly modified by the code), but the results aren’t updating at the first time. I’ve got to change manually the default filter (eg : 12 months ago…) and go back to “All” to print the real history.

    Any ideas?

    Sincerely, Thomas.

  8. May 9, 2007 at 4:51 pm

    The view combo box uses a style sheet that references a HTML control. We have to wait until the htc file is loaded, otherwise the call to FireOnChange in the SetDefaultView method will fail. So you need to wait untill the whole form loads. Otherwise try this little trick, i am not sure but it may works. Try replaceing areaActivityHistoryFrame_OnReadyStateChange function with:

    areaActivityHistoryFrame_OnReadyStateChange = function() {
    if (document.readyState == “complete”) {
    var frame = document.frames(“areaActivityHistoryFrame”);
    var viewCombo = frame.document.getElementById(“actualend”);
    viewCombo.onreadystatechange = function() {
    if (this.readyState == “complete”) {
    SetDefaultView(this, “All”);

    Hope this helps.



  9. May 25, 2007 at 4:06 pm

    I also had the same problem and neither the original or altered function you list here seems to allow the script enough time to allow the controls to completely load consistently. I don’t think the readystate is reliable in javascript in really being ready. If you place an alert before the setdefaultview function then it has time to load and it work but obviously we can’t do that. I thought about some form of a sleep command but that doesn’t really exist in javascript and isn’t something we want to do anyway. What I ended up doing, maybe not a great solution but seems to work, was to force an error to occur and trap it with a try/catch so it doesn’t display an error and doing that must give it enough time to finish loading and the code worked consistently.

  10. john
    June 26, 2007 at 12:10 pm

    Hi Ayaz

    I cant get the code to work. I copied it to the Account on Load event, It gives me an object expected error at the line below

    document.frames(“areaActivityHistoryFrame”).document.onreadystatechange = areaActivityHistoryFrame_OnReadyStateChange;

    Anny ideas

  11. Ram
    July 19, 2007 at 11:03 am

    Hi Friends,

    i’m new for this area MS-CRM. i’m working with MS-CRM with Agent Interaction Library SDk. Now i need to get an Activity Id from CRM window. How to do this. please help me.

  12. tom
    July 19, 2007 at 2:32 pm


    I’ve exactely the same problem as Michael Wahlman and Thomas.

    Any ideas?

  13. July 19, 2007 at 9:02 pm

    Sorry for the delay. I checked the code again and found the problem. At least I hope it was the problem. Please open the article again (http://www.stunnware.com/crm2/topic.aspx?id=JS11) for more information.


  14. tom
    July 20, 2007 at 10:33 am


    It worked perfectly


  15. Marko
    November 7, 2007 at 9:10 am


    To turn on debugging info in CRM goto:
    “web.config” (somewhere in inetpub\wwwroot… look for “” and change it to “On”

  16. Marko
    November 7, 2007 at 9:18 am

    add key=”DevErrors” value=”Off”

  17. Jen
    November 13, 2007 at 9:04 pm

    I am trying to use the code provided, but I keep getting an object expected error at the line below:
    document.frames(”areaActivityHistoryFrame”).document.onreadystatechange = areaActivityHistoryFrame_OnReadyStateChange
    I have placed the code into the OnLoad event on the Account form and have removed all comments. Everything appears to work fine until it gets to the above line. Any ideas? I believe someone else asked this question earlier, but I never saw a response to it except for the newer piece of code, which I am trying to use. Any help would be much appreciated!

  18. November 14, 2007 at 12:33 pm

    Hi Jen,

    I have faced similar problems. Please check this updated article for more info. http://www.stunnware.com/crm2/topic.aspx?id=JS11


  19. Jen
    November 14, 2007 at 8:19 pm

    I have tried using the code on the site referenced, but am still receiving a javascript error Object required. It is the last line that seems to be causing the error message:
    document.frames(“areaActivityHistoryFrame”).document.onreadystatechange = areaActivityHistoryFrame_OnReadyStateChange;

    Any further suggestions, would be much appreciated.

  20. Jen
    November 16, 2007 at 7:07 pm

    I believe I have found this to be an issue with internet explorer/javascript on the machine I was testing this on. Once I moved to another machine, the code functioned fine.

  21. NSS
    June 18, 2008 at 5:24 pm

    Has anyone modified this code to work in CRM 4.0? It was working well in 3.0 and I know there was a disclaimer about it working in the next version.

  22. December 13, 2008 at 5:14 pm


  1. No trackbacks yet.

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 )

Connecting to %s

%d bloggers like this: