Skip to content

Releases: hso-nn/crm-sdk

Metadata.getOptionSet should always return an array

22 Dec 13:57
Compare
Choose a tag to compare

Metadata.getOptionSet(logicalName, attribute) returns array even if no OptionSet is found.

Metadata.getEntityDefinitions uses promise cache to prevent redundant requests

22 Dec 11:24
Compare
Choose a tag to compare

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

20 Dec 15:51
Compare
Choose a tag to compare

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

04 Dec 10:59
Compare
Choose a tag to compare

From now the parameter associateEntityId is optional. Which can be handy for single-valued navigation property.

Add Entity.instantiate

01 Dec 08:41
Compare
Choose a tag to compare

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

27 Nov 14:57
Compare
Choose a tag to compare
import {Context} from "crmsdk";

// or

var Context = CRMSDK.Context;

Translation support (migration needed)

27 Nov 13:32
Compare
Choose a tag to compare

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

21 Nov 09:00
Compare
Choose a tag to compare
const searchObj = WebAPI.urlQueryString(/*window.location.search*/);

Bearer support

20 Oct 07:27
Compare
Choose a tag to compare

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

17 Oct 11:16
Compare
Choose a tag to compare

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
});