Javasript Software Development Kit for Microsoft Dynamics CE Web API
npm install crm-sdk
sh
$ npm install crm-sdk
`
#### Modules
`javascript
//app.js
import {WebAPI} from "crm-sdk";
WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {
//todo logic here
});
`
#### Require
`javascript
//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
});
`
$3
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
`
In app.js, The WebAPI will be available on window.CRMSDK scope. Example for using WebAPI below:
`javascript
//app.js
var WebAPI = window.CRMSDK.WebAPI;
WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8").then(function (data) {
//todo logic here
});
`
WebAPI example
$3
`html
`
$3
`javascript
WebAPI.retrieveEntity("account", "475b158c-541c-e511-80d3-3863bb347ba8")
.then(function (accountData) {
WebAPI.updateEntity("account", accountData.accountid, {
emailaddress1: "test2@company.com"
}).then(function (data) {
console.log("saved " + data.accountid);
});
});
`
Entity abstraction example
$3
`html
`
$3
`javascript
var WebAPI = CRMSDK.WebAPI;
var Entity = CRMSDK.Entity;
Entity.get("account", "475b158c-541c-e511-80d3-3863bb347ba8")
.then(function (account) {
account.emailaddress1 = "test2@company.com";
account.save().then(function () {
console.log("saved! " + account.accountid);
});
});
``