Defaulting the History ‘Filter on’ to ‘All’ on Dynamics CRM 4.0 Accounts and Contacts

Paul Nieuwelaar, 21 July 2010

When you open up an Account or Contact in Dynamics CRM 4.0, and click on the History tab, by default it shows the history for the ‘last 30 days’ on that record. So if you want to view all the history for the Account or Contact, you have to manually change the ‘Filter on’ drop down to ‘All’ every time.

It is possible to overwrite this, and make the default filter for History set to ‘All’. To do this you need to add a few lines of JavaScript to the Forms OnLoad event.

1. Navigate to Settings, Customizations and then Customize Entities.

2. Open the Account entity (this will work on Account or Contact, but I recommend doing it on both).

3. Click on Forms and Views, and open the main Form.

4. Click Form Properties and then click Edit for the OnLoad.

5. Copy the code below, and then paste it into the OnLoad.

// History Default Filter to All

var crmloadarea = loadArea;

loadArea = function (area) {

    crmloadarea(area);

    if (area != "areaActivityHistory") { return; } // only hook into the history iframe

 

    var frame = document.getElementById(area + "Frame");

    frame.onreadystatechange = function () {

        if (frame.readyState == "complete") {

            doc = frame.contentWindow.document;

            doc.all.actualend[0].value = "All"; // instead of 30 days

            doc.all.actualend[0].FireOnChange();

        }

    }

}

 

6. The code above does not need to be modified for different entities; it will work as is on both the Account and Contact.

7. Click Ok twice, and Save and Close the Form.

8. Publish the customizations, and then open the Account or Contact you added the code to. Check that on the History tab the ‘Filter on’ drop down is defaulted to ‘All’

9. Repeat the above for Contact, to paste the same code into the Contact OnLoad event.

That’s all there is to it, now whenever you open an existing Account or Contact, the History will default to ‘All’ instead of ‘Last 30 days’.