In such case, if we use the HTML page instead of the javascript then you can load the related script library with the following line of code.
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);
}
}
}