Changing default filter for Contracts Associated View for Account.

For an account record, the associated view of Contract would have default filter set as Draft. So if we want to change it to some other status for example “Active” we can make use of the following JavaScript for that.

This JavaScript is based on the popular JavaScript code used for hiding “add existing button”

Please check this wonderful article

http://blog.davehawes.com/post/2008/04/23/MSCRM-4-Remove-Add-Existing-xxxxx-button.aspx

The JavaScript code for changing default option

var navElement = document.getElementById('navContracts');
 if (navElement != null) {
  navElement.onclick = function LoadAreaOverride()  {
   loadArea('areaContracts');
   SetDefaultOption(document.getElementById('areaContractsFrame'));
  }
 }

function SetDefaultOption(Iframe) {
 if (Iframe != null ) {
  Iframe.onreadystatechange = function SetOption() {
   if (Iframe.readyState == 'complete') {
    var iFrame = frames[window.event.srcElement.id];
    var selectBox=iFrame.document.getElementById('statecode');
     selectBox.options[2].selected=true;
   }
  }
 }

http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/85615ccd-b8e9-48d3-a906-4fd7b301dac0

Bye..


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

1 thought on “Changing default filter for Contracts Associated View for Account.”

Share your thoughts

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