Releases: hso-nn/crm-sdk
Metadata.getOptionSet should always return an array
Metadata.getOptionSet(logicalName, attribute) returns array even if no OptionSet is found.
Metadata.getEntityDefinitions uses promise cache to prevent redundant requests
When Entity and/or WebAPI did multiple requests at the same time for the same LogicalName, the Metadata.getEntityDefinitions method did redundant requests. Promise cache will prevent that now.
WebAPI.getOptionSet returns externalValue
WebAPI.getOptionSet returns externalValue as well.
WebAPI.getOptionSet("account", "industrycode").then(function (options) {
options.forEach(function (option) {
console.log(option.label + " " + option.value + " " + option.externalValue);
});
}).catch(function (e) {
throw e;
});
Add disassociateEntities for single-valued navigation property
From now the parameter associateEntityId is optional. Which can be handy for single-valued navigation property.
Add Entity.instantiate
Instantiate a new entity.
Entity.instantiate({
paymenttermscode: 4,
statecode: 0,
emailaddress1: "instantiate@dys.nl"
}, "account").then(function (account) {
console.log("entity.instantiate 'account' " + account.emailaddress1);
account.save(); // create the account in CRM.
});
Add missing export of Context
import {Context} from "crmsdk";
// or
var Context = CRMSDK.Context;
Translation support (migration needed)
Translation
Translation support added:
Translation.init({
relativePath: "new_/locales"
}).then(t => {
console.log(Translation.translate("test"));
}).catch(e => {
throw e;
});
Migration steps
- CRMSDK.WebAPI.clientUrl => CRMSDK.Context.clientUrl
- CRMSDK.WebAPI.version => CRMSDK.Context.version
- CRMSDK.WebAPI.context => CRMSDK.Context.context
- CRMSDK.WebAPI.version => CRMSDK.Context.version
- WebAPI.urlQueryString => removed!
WebAPI.urlQueryString to parse location.search to Object
const searchObj = WebAPI.urlQueryString(/*window.location.search*/);
Bearer support
When running from outside CRM in NodeJS for example, you can pass the Bearer.
// NodeJS code
const CRMSDK = require("CRMSDK"),
WebAPI = CRMSDK.WebAPI;
WebAPI.bearer = "<your-accessToken>";
WebAPI.version = "v8.2";
WebAPI.clientUrl = "<url-to-your-crm-environment>";
...
Webresource support
Webresource is a sub-class of Entity. It can be included in your application the same way.
The Webresource will make it easy to modify webresources.
Publishing is included in the save (save === upload + publish).
import {Webresource} from "crm-sdk";
// update example
let webresource = Webresource.get(null, {
name: webresourceName,
select: ["name", "webresourcetype"]
}).then(function (webresource) {
webresource.content = "<base64 string here>";
webresource.save().then(function () {
// saved and published
});
});
// insert example
webresource = new Webresource({
content: "<base64 string here>",
name: "<filename>",
displayname: "<displayname>"
});
webresource.solutionUniqueName = "<solution name>"; // otherwise "Active" solution will be taken
webresource.save().then(function () {
// saved and published
});