Home > MS CRM 4.0 > Changing the default view of related entities(Filter On)

Changing the default view of related entities(Filter On)


I came across many client where they always need to see all records in releated entity rather than filtering based on statecode or created on .
Let’s take the history view in an account form. It defaults to the "Last 30 days".

Many people think it’s better to see all items instead and as there is no option to specify the default view, they have to open the view list and select the "All" view. When working with the history view a lot, this is a time-consuming and bothering job.

Changing the default view

Here I’m setting View to show all opportunities in Account related entity.

//Opportunity statecode options

var OppOptions = { All: "All", Open: "Open", Won: "Won", Lost: "Lost" }

try

{

var _loadarea = loadArea;

loadArea =

function(sArea, sParams, sUrl, bIsvMode) {

//load the iframe

_loadarea(sArea, sParams, sUrl, bIsvMode);

if (sArea != "areaOpps") 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 "areaOpps":

picklist = iframeDoc.all.statecode[0];

/* change to suit your needs */

option = OppOptions.All;

break;

default: return;

}

picklist.value = option;

picklist.FireOnChange();

}

}

}

}

catch

(e) {

}

If you remove the comments, the code becomes quite handy, but I thought it’s critical to understand what is happening, before you make changes. And as this is an unsupported change and has a very good chance to break in the next CRM version, you really should know how it works.

The code has to be placed in the account’s OnLoad event.

Advertisements
Categories: MS CRM 4.0
  1. No comments yet.
  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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: