MS CRM 2011: My first experience. Adding OnLoad event script.

Today I've started studing functionality of new MS CRM 2011. I want to descover client scripting first and today I've added OnLoad event script. I want to share steps I've made to add script on the form.

Addressable form for displaying activities' views

There are two different forms to display views in MS CRM 4. One for activities' views and the other one to dispaly other entities' views.

I used to use following code to generate url for addressable form to display particular view:

Recently I found that homepage.aspx incorectly displays activities' views. Columns From and To were empty:

The right way is to use home_activities.aspx if you want to display activities' views. The code was changed to:

home_activities.aspx displays activities as shown here:

You can read more about addressable forms here:

HOW TO: Resize MS CRM forms to fit screen size

Read this post if you want one wiondow or all to fit screan size.

If you need only one form to fit screan size you can add following code in the OnLoad event:
    window.moveTo(0, 0);
    window.resizeTo(screen.availWidth, screen.availHeight);

Three easy steps are needed to make all CRM 4.0 forms to fit screen size:
  1. Locate global.js file ([Path to Microsoft Dynamics CRM folder]\_static\_common\scripts\global.js) and open it

  2. Locate safeWindowShowModelessDialog function and change it as shown below:

  3. Locate safeWindowOpen function and change it as shown below:

Code needs to be inserted in safeWindowOpen and safeWindowShowModelessDialog:
    windowOpened.window.moveTo(0, 0);
    windowOpened.window.resizeTo(screen.availWidth, screen.availHeight);