locked
Activities associated view RRS feed

  • Question

  • Hi
    Does anyone know if you chan change the default view when looking at the activites list under an account? I am trying to change the view to show "this record only" and not "Related regarding records".


    cheers
    Tuesday, April 7, 2009 11:05 AM

Answers

  • Based on some code that Michael Hohne posted on Stunnware (http://www.stunnware.com/crm2/topic.aspx?id=js33) from code sent to him by Jonathan Briggs from SoftArtisans, here's some unsupported code that should help. Put this in the OnLoad event for the Account:

    /**************************************************************
    * Change the default view of a view selection combo box
    **************************************************************/
    SetDefaultView = function(viewCombo, viewName, appGrid) {
    
        /* If the view has already been set, we don't need to do it again. */
        if (viewCombo.value != viewName) {
    
            /* Set the new view */
            viewCombo.value = viewName;
    
            /* Call RefreshGridView to run the code in the DHTML control.
             * Without this call, only the selection in the combo box changes,
             * but not the content of the grid */
            appGrid.RefreshGridView();
        }
    }
    
    /**************************************************************
    * Event handler. Called whenever the ready state of the
    * areaActivityHistoryFrame changes.
    **************************************************************/
    areaActivityHistoryFrame_OnReadyStateChange = function() {
    
        /* Waiting until the frame has finished loading */
        if (this.readyState == "complete") {
    
            /* This is the frame we're interested in */
            var frame = document.frames("areaActivityHistoryFrame");
    
            /* And this is the view combo box */
            var viewCombo = frame.document.getElementById("ViewControl");
    
            /* This is the AppGridFilterContainer control we need to refresh the view */
            var appGrid = frame.document.getElementById("AppGridFilterContainer");
    
            /* 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. */
            if (viewCombo.readyState == "complete") {
    
                /* If the control already has finished loading, we can
                 * directly set the new view. */
                SetDefaultView(viewCombo, "ImmediateRelatedView", appGrid);
            }
    
            else {
                /* Otherwise we have to register another event handler
                * waiting until all of the include files used by the
                * combo box are loaded as well. */
                viewCombo.onreadystatechange = function() {
                    if (this.readyState == "complete") {
                        SetDefaultView(this, "RollupRelatedView", appGrid);
                    }
                }
            }
        }
    }
    
    /* Set a new onclick event for the History navigation element
     * This is where we register the onreadystatechange event handler */
    if (document.getElementById('navActivityHistory') != null) {
        document.getElementById('navActivityHistory').onclick = function() {
            loadArea('areaActivityHistory');
            document.frames('areaActivityHistoryFrame').document.onreadystatechange = areaActivityHistoryFrame_OnReadyStateChange;
        }
    }
    
    

    Matt Wittemann, MVP for CRM (http://www.mscrm4.com)
    Tuesday, April 7, 2009 6:37 PM
    Moderator

All replies

  • Based on some code that Michael Hohne posted on Stunnware (http://www.stunnware.com/crm2/topic.aspx?id=js33) from code sent to him by Jonathan Briggs from SoftArtisans, here's some unsupported code that should help. Put this in the OnLoad event for the Account:

    /**************************************************************
    * Change the default view of a view selection combo box
    **************************************************************/
    SetDefaultView = function(viewCombo, viewName, appGrid) {
    
        /* If the view has already been set, we don't need to do it again. */
        if (viewCombo.value != viewName) {
    
            /* Set the new view */
            viewCombo.value = viewName;
    
            /* Call RefreshGridView to run the code in the DHTML control.
             * Without this call, only the selection in the combo box changes,
             * but not the content of the grid */
            appGrid.RefreshGridView();
        }
    }
    
    /**************************************************************
    * Event handler. Called whenever the ready state of the
    * areaActivityHistoryFrame changes.
    **************************************************************/
    areaActivityHistoryFrame_OnReadyStateChange = function() {
    
        /* Waiting until the frame has finished loading */
        if (this.readyState == "complete") {
    
            /* This is the frame we're interested in */
            var frame = document.frames("areaActivityHistoryFrame");
    
            /* And this is the view combo box */
            var viewCombo = frame.document.getElementById("ViewControl");
    
            /* This is the AppGridFilterContainer control we need to refresh the view */
            var appGrid = frame.document.getElementById("AppGridFilterContainer");
    
            /* 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. */
            if (viewCombo.readyState == "complete") {
    
                /* If the control already has finished loading, we can
                 * directly set the new view. */
                SetDefaultView(viewCombo, "ImmediateRelatedView", appGrid);
            }
    
            else {
                /* Otherwise we have to register another event handler
                * waiting until all of the include files used by the
                * combo box are loaded as well. */
                viewCombo.onreadystatechange = function() {
                    if (this.readyState == "complete") {
                        SetDefaultView(this, "RollupRelatedView", appGrid);
                    }
                }
            }
        }
    }
    
    /* Set a new onclick event for the History navigation element
     * This is where we register the onreadystatechange event handler */
    if (document.getElementById('navActivityHistory') != null) {
        document.getElementById('navActivityHistory').onclick = function() {
            loadArea('areaActivityHistory');
            document.frames('areaActivityHistoryFrame').document.onreadystatechange = areaActivityHistoryFrame_OnReadyStateChange;
        }
    }
    
    

    Matt Wittemann, MVP for CRM (http://www.mscrm4.com)
    Tuesday, April 7, 2009 6:37 PM
    Moderator
  • Thanks

    Works like a dream

    :)

    cheers
    Wednesday, April 8, 2009 9:40 AM