In Dynamics CRM 2011, if we implement JavaScript for particular form we add script web resource in the Form Libraries list under form customization, if there is any related script which need to be referred, then we need to include that script as well in the Form Libraries. As you can see in the below screen, we have included “new_SDK.Rest” and “new_Json2”. We have not called the function of those scripts in the “Event Handlers”, but we have used them in our library “new_Account_Library.jsa
Here the problem is how to add/ load related JScript reference like in this case sdk.rest jscript and json Jscript reference. To retrieve the data from CRM we generally use functions from the sdk.rest library. Hence this library “sdk.rest” needs to be loaded as we are referring the function of “sdk.rest” library in this “new_Account_Library.js” script.
So to resolve this we can simply load referred web resource from JScript programmatically before performing our business logic, below is the function you can refer to.
We need to pass name of web resource.
LoadWebResource(“Name of the Web Resource”);
e.g.
LoadWebResource(“new_json2”)
LoadWebResource(“new_SDK.Rest”)
Function for load web resource:
var httpRequest = null;
try {
}
}
var serverUrl= Xrm.Page.context.getServerUrl();
if (serverUrl.match(/\/$/)) {
serverUrl = serverUrl.substring(0, serverUrl.length – 1);
}
httpRequest.send(null);
eval(httpRequest.responseText);
}
alert(“LoadWebResource >> Error loading ” + resource + “:\n” + e.description);
}
}

