At times it is helpful to change the document title of a form. In case you aren't familiar with the term, the document title refers to the text that appears at the top of the tab or window (depending on your Internet Explorer preferences) of a form in MS CRM.

For example, the document title of the form below is "Account: Microsoft" ... which is the default text for the Account form.

The default text is fine most of the time, but occassionally we identify a need to change the text to provide additional information to the user. For example, the default document title for the case form is "Case:" followed by the case number:

 

When a user glances at the document title, the case number by itself often isn't extremely useful. Some additional information would be helpful, such as the account name or the case title.

The basic steps to change a document title are pretty simple: from within the "Form Properties" of the form, go to the "Events" tab, highlight "OnLoad", and click "Edit". Make sure the checkbox to enable the event is checked, and then enter the following code:

document.title = "Case"

After saving and publishing your customization, the new document title will simply be "Case" whenever you open the case form. That change by itself probably wouldn't be very helpful - so let's now take it a step further. Replace your previous line of code with the following:

var lookup = crmForm.all.customerid.DataValue;

 if (lookup[0] != null) {
    var acctName= lookup[0].name;
}
var caseName = crmForm.all.title.DataValue;

document.title = acctName +": "+ caseName

Now the account name is retrieved through the "customerid" lookup control, and is followed by the title of the case. The resulting document title will be much more descriptive: