Saturday, September 29, 2007

Reference javascript file in Form_onLoad Event of an Entity.

Reference javascript file in Form_onLoad Event of an Account Entity.

Create a sub virtual directory under MS CRM Virtual root directory and place your .JS files in sub virtual directory.

E.G.,
Name of the sub virtual directory under MS CRM Virtual root directory is: "Customizations".
and Name of the JavaScript file you have created is "Account_Entity_Customizations.js"

Go to
Settings => Customizations => Custom Entitites => Select Account Entity => Open (double click) => Forms and Views => Form =>Form Properties => Edit OnLoad Event.

Copy paste below code in the OnLoad Event Box (select enable javascript event check box):

var oScript_Account = document.createElement("<script src='/Customizations/Account_Entity_Customizations.js' language='JavaScript'>");
 
document.getElementsByTagName("head")[0].insertAdjacentElement("beforeEnd", oScript_Account); 

Save and Publish the Entity.

Refresh MS CRM Portal.

Open Account Entity, you will see your JavaScript code working.

Happy Coding !!!!!!!!!!!!!!.