Nov 7, 2011

Referring JavaScript files

Referring the JavaScript files in CRM 2011 is pretty straight forward. You have been given a room for doing it in customization area as below.
So this is easy. Once a file is added to this space, all the methods in it become available to use.

Anyway, when you call a method from the Ribbon, it’s not the case. You can simply mention a file and method as below. In this case our method is called CalculateCost(). We can now call only the functions in this file only.

  <JavaScriptFunction Library="$webresource:new_Cal.js" FunctionName="CalculateCost">

If we need to access some other JavaScript method in some other file (a web resource), how we are going to achieve it? Well, I managed to do it this way. Suppose, we need to access another method from CalculateCost which is in another file called new_Utilities. This is how I am going to call them.

function InjectScript(scriptFile)
  var netRequest = new ActiveXObject("Msxml2.XMLHTTP");"GET", scriptFile, false);
  return netRequest.responseText;

function CalculateCost()

  //now all the methods in new_Utilities can be called 

Hope this will help.

No comments:

Post a Comment