Muhammad Ali Khan

MS CRM 3.0, MS CRM 4.0, Sharepoint 2007 & Sharepoint 2010

Posts Tagged ‘MS CRM Javascript’

Show The Associated View On CRM Entity Load

Posted by Ali Khan on February 16, 2010

Hello, Today i just want to share a small MS CRM JavaScript. As we know once any MS CRM Entity form load, the default view is the “Information” view of the entity, as see below for my account form.


What if i want to “Quotes” grid to appear as soon as the Account form is open. Well its really one line of JavaScript (First find the id of the left navigation node, thanks to the IE8, it is very easy now, press F12 to launch the debugger tools, find the element by “Search element by Click” option and there you have the element id as shown below)


So here is the script for the form OnLoad() event.

  1: if(crmForm.FormType == 2)
  2: {
  3:   document.getElementById('navQuotes').click();
  4:   document.getElementById('_NA_Info').click();
  5: }

and here is how my “Account” form once it loads( i also collapsed the “Details Node” for better view ability). Now once i double click any account in my main grid, by defaults, it loads the “Associated Quotes View” of the “Account”.


That’s all.


Posted in MS CRM 3.0, MS CRM 4.0 | Tagged: | 1 Comment »

Add More Values to Duration(Drop-Down) In MS-CRM 4.0 Task Entity

Posted by Ali Khan on January 24, 2010

In this small post, i will show you how to add more options(Values) to the Standard “Duration” drop-down in the “Task” Entity. So, out of the box, the “Duration” field on the “Task” entity look like this.


Note:- “Duration” Field is not a MS CRM Pick-List. It is editable and user can add anything e.g. “4 Days”, “52 Minutes” etc. In fact the data type of the “Duration” field is “Integer”. but in Task entity it looks like a Standard MS CRM Pick list. In-Background MS CRM is generating a table for this field and displaying the values in the drop-down. See the attribute description below:-


So to add more values to the “Duration” drop-down, put the following JavaScript code in the Task Entity Form ==> OnLoad() event, save the form and publish the “Task” entity. The code is simply adding rows to the table, which is used to display the “Duration” drop-down on “Task” Entity Form.

var obj = document.getElementById('actualdurationminutesSelect');
var tbl = obj.childNodes[1];
var lastRow = tbl.rows.length;
var row = tbl.insertRow(lastRow);
var cell = row.insertCell(0);
cell.val = '4 days';
cell.innerText = '4 days';
row = tbl.insertRow(lastRow);
var cell = row.insertCell(0);
cell.val = '5 days';
cell.innerText = '5 days';

After publishing the “Task” entity, the “Duration” drop-down now look like this, with values “4 days” & “5 days” coming inside the default drop-down.


That’s all folks !!!

Posted in MS CRM 3.0, MS CRM 4.0 | Tagged: | 3 Comments »