Hi All,
Recently I have a piece of html web resource containing some JavaScript code which utilize the latest Dynamics CRM V9 client API for creating/updating records.
The html page contains some simple button and already included the clientGlobalcontext.js
(for getting the Xrm namespace)
<script src="../../clientGlobalcontext.js.aspx"></script>
The code example is as the following:
var contactObj = new Object();
contactObj ["firstname"] = "John";
contactObj ["lastname"] = "Smith";
Xrm.WebApi.createRecord("contact", contactObj).then(successCallBack, errorCallBack);
However, the code seems does not working. It throwing an error in my error call back method, and complaining "contact" property is null or undefined.
Then I have to switch the code by using the old fashioned XMLHttpRequest to perform a web api call. Which works normal.
Using the code like the following:
var req = new XMLHttpRequest();
req.open("POST", encodeURI(Util.getWebAPIEndpoint() + type), true);
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.onreadystatechange = function () {
//.....
}
So just one question:
Is it possible to use the standard wrapped Xrm.WebApi (CRUD) methods in Dynamics V9.0 html webresources (for example, html pages)?
Many thanks.
Regards
Harry
*This post is locked for comments