Quantcast
Channel: MS CRM Customization Fun » SDK
Viewing all articles
Browse latest Browse all 2

Speed up development with external JavaScript files

$
0
0

When creating complicated JavaScript for MS CRM it can be easier to place your code in an external JavaScript file while developing. This content of this file will be loaded and executed in the onload event of the form.

To load this file place the following code in the onload event.

var url = “‘/ISV/” + ORG_UNIQUE_NAME + “/javascripts/” + crmForm.ObjectTypeName + “.js’”;
st = document.createElement(“<script src=” + url + ” language=’JavaScript’>”);
h = document.getElementsByTagName(“head”);
h[0].insertAdjacentElement(“beforeEnd”, st);

 For this to work your file need to be saved like this
<<MS CRM Website>>\ISV\<<Organization Name>>\javascripts\<<entity name>>.js

For example:
I want to create a javascript file to be loaded in the onload of an account form (for the organization advworks). On my development server I first create a file at the following location:
c:\Inetpub\Microsoft Dynamics CRM\ISV\advworks\javascripts\account.js

Next I cut and paste the above JavaScript code in the onload event of the account save and publish it.
Notice I don’t need to change or configure the javascript code in order to make this work! This also works for custom entities.

Al I have to do is start writing JavaScript code in de account.js file, save the file and open an account in MS CRM.

By doing this you can save a lot of time because you don’t need to save your script in the form properties and open the preview form or publish every time if you want to test with live data.

This method is not supported so make sure that after you created and tested your script you cut and paste your script from the file to the onload of the form and remove the JavaScript that loads up your external file.

Happy scripting


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images