Javascript Software Development Kit for Dynamics CRM Web API.
There are several SDK's available, so why another one?
- This library does paging for you (using @odata-nextLink to do multiple requests)
- This library always finds correct entitySetName (which is not always: LogicalName + 's')
- This library is promise based
- This library supports modules
- This library supports default WebAPI like other libraries, but also
- This library supports extra Entity abstraction
- This library supports annotations
- This library supports getting OptionSet
- This library supports Webresource uploading/publishing
$ npm install crm-sdk
//app.js
import {WebAPI} from "crm-sdk";
WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {
//todo logic here
});
//app.js
var CRMSDK = require("crm-sdk"); //umd
var WebAPI = CRMSDK.WebAPI;
WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {
//todo logic here
});
Download latest release and put reference to dist/CRMSDK.js in your index.html.
In example below, the app.js is your own application code. If you only need CRMSDK.WebAPI, you can include WebAPI.js in index.html instead of CRMSDK.js.
<html>
<body>
<script type="text/javascript" src="CRMSDK.js"/>
<script type="text/javascript" src="app.js"/>
</body>
</html>
In app.js, The WebAPI will be available on window.CRMSDK scope. Example for using WebAPI below:
//app.js
var WebAPI = window.CRMSDK.WebAPI;
WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {
//todo logic here
});
<html>
<body>
<script type="text/javascript" src="WebAPI.js"/>
<script type="text/javascript" src="app.js"/>
</body>
</html>
WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8")
.then(function (accountData) {
WebAPI.updateEntity("account", accountData.accountid, {
emailaddress1: "[email protected]"
}).then(function (data) {
console.log("saved " + data.accountid);
});
});
<html>
<body>
<script type="text/javascript" src="CRMSDK.js"/>
<script type="text/javascript" src="app.js"/>
</body>
</html>
var WebAPI = CRMSDK.WebAPI;
var Entity = CRMSDK.Entity;
Entity.get("account", "475b158c-541c-e511-80d3-3863bb347ba8")
.then(function (account) {
account.emailaddress1 = "[email protected]";
account.save().then(function () {
console.log("saved! " + account.accountid);
});
});
Code and documentation copyright 2011-2017 Dynamics Software. Code released under the MIT License.