I have created following simple web resource in dynamics CRM, to use rest API using OData. Please consider, new_JavaScriptRESTDataOperationsSample is sample with SDK, I have only created following sample HTML.
<HTML><HEAD><TITLE>OData</TITLE>
<META charset=utf-8></HEAD>
<BODY>
<SCRIPT type=text/javascript src="ClientGlobalContext.js.aspx"></SCRIPT>
<SCRIPT type=text/javascript src="new_SDK.REST"></SCRIPT>
<SCRIPT type=text/javascript src="new_json2"></SCRIPT>
<SCRIPT type=text/javascript src="new_JavaScriptRESTDataOperationsSample"></SCRIPT>
<BUTTON onclick=createAccount();>Click Me!</BUTTON></BODY></HTML>
When I click on Click Me! button it gives following errors,
Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR
3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3) Timestamp: Mon, 29 Sep 2014 07:38:45 UTC
Message: 'startButton' is null or not an object Line: 32 Char: 3 Code: 0 URI: http://dynamicscrm01/CRM01/%7B635475719080000809%7D/WebResources/new_JavaScriptRESTDataOperationsSample
Message: 'output' is null or not an object Line: 199 Char: 2 Code: 0 URI: http://dynamicscrm01/CRM01/%7B635475719080000809%7D/WebResources/new_JavaScriptRESTDataOperationsSample
Sorry for incorrect formatting, SO not allowing links in block quotes.
the MSDN sample sample_/Scripts/JavaScriptRESTDataOperationsSample
is connected to the sample_/JavaScriptRESTDataOperationsSample.htm
web resource.
Sample: Create, retrieve, update, and delete using the OData endpoint with JavaScript
If you look inside the CreateAccount
function you will find these lines:
startButton = document.getElementById("start");
output = document.getElementById("output");
so the script is expecting that inside the HTML file these objects are present. In your example you only include the button, but the sample_/JavaScriptRESTDataOperationsSample.htm
web resource contains the requested objects:
<button id="start" title="Click this button to start the sample.">
Start</button>
<button id="reset" title="Click this button to reset the sample." disabled="disabled">
Reset</button>
<ol id="output">
</ol>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.