Skip to content

Commit

Permalink
Release v1.5.13
Browse files Browse the repository at this point in the history
  • Loading branch information
AleksandrRogov committed Nov 11, 2019
1 parent 98d8be7 commit 0d70184
Show file tree
Hide file tree
Showing 6 changed files with 86 additions and 58 deletions.
66 changes: 40 additions & 26 deletions dist/dynamics-web-api-callbacks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! dynamics-web-api-callbacks v1.5.12 (c) 2019 Aleksandr Rogov */
/*! dynamics-web-api-callbacks v1.5.13 (c) 2019 Aleksandr Rogov */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
Expand Down Expand Up @@ -168,13 +168,13 @@ function generateUUID() { // Public Domain/MIT
}

function getXrmContext() {
if (typeof GetGlobalContext != 'undefined') {
if (typeof GetGlobalContext !== 'undefined') {
return GetGlobalContext();
}
else {
if (typeof Xrm != 'undefined') {
if (typeof Xrm !== 'undefined') {
//d365 v.9.0
if ((!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext))) {
if (!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext)) {
return Xrm.Utility.getGlobalContext();
}
else if (!isNull(Xrm.Page) && !isNull(Xrm.Page.context)) {
Expand Down Expand Up @@ -203,11 +203,11 @@ function initWebApiUrl(version) {

function getXrmInternal() {
//todo: Xrm.Internal namespace is not supported
if (typeof Xrm !== 'undefined') {
return Xrm.Internal;
}
return typeof Xrm !== "undefined" ? Xrm.Internal : null;
}

return null;
function getXrmUtility() {
return typeof Xrm !== "undefined" ? Xrm.Utility : null;
}

var Utility = {
Expand Down Expand Up @@ -249,6 +249,8 @@ var Utility = {

getXrmInternal: getXrmInternal,

getXrmUtility: getXrmUtility,

getClientUrl: getClientUrl,

initWebApiUrl: initWebApiUrl
Expand Down Expand Up @@ -775,7 +777,8 @@ var _entityNames;
*/
function findCollectionName(entityName) {
var xrmInternal = Utility.getXrmInternal();
if (!Utility.isNull(xrmInternal)) {

if (!Utility.isNull(xrmInternal) && typeof xrmInternal.getEntitySetName === "function") {
return xrmInternal.getEntitySetName(entityName) || entityName;
}

Expand All @@ -785,7 +788,7 @@ function findCollectionName(entityName) {
collectionName = _entityNames[entityName];
if (Utility.isNull(collectionName)) {
for (var key in _entityNames) {
if (_entityNames[key] == entityName) {
if (_entityNames[key] === entityName) {
return entityName;
}
}
Expand Down Expand Up @@ -989,26 +992,37 @@ function sendRequest(method, path, config, data, additionalHeaders, responsePara

function _getEntityNames(entityName, config, successCallback, errorCallback) {

var resolve = function (result) {
_entityNames = {};
for (var i = 0; i < result.data.value.length; i++) {
_entityNames[result.data.value[i].LogicalName] = result.data.value[i].LogicalCollectionName;
}
var xrmUtility = Utility.getXrmUtility();

successCallback(findCollectionName(entityName));
};
//try using Xrm.Utility.getEntityMetadata first (because D365 caches metadata)
if (!Utility.isNull(xrmUtility) && typeof xrmUtility.getEntityMetadata === "function") {
xrmUtility.getEntityMetadata(entityName).then(function (response) {
successCallback(response.EntitySetName);
}, errorCallback);
}
else {
//make a web api call for Node.js apps
var resolve = function (result) {
_entityNames = {};
for (var i = 0; i < result.data.value.length; i++) {
_entityNames[result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;
}

var reject = function (error) {
errorCallback({ message: 'Unable to fetch EntityDefinitions. Error: ' + error.message });
};
successCallback(findCollectionName(entityName));
};

var request = RequestConverter.convertRequest({
collection: 'EntityDefinitions',
select: ['LogicalCollectionName', 'LogicalName'],
noCache: true
}, 'retrieveMultiple', config);
var reject = function (error) {
errorCallback({ message: 'Unable to fetch EntityDefinitions. Error: ' + error.message });
};

var request = RequestConverter.convertRequest({
collection: 'EntityDefinitions',
select: ['EntitySetName', 'LogicalName'],
noCache: true
}, 'retrieveMultiple', config);

sendRequest('GET', request.url, config, null, request.headers, null, resolve, reject, false, request.async);
sendRequest('GET', request.url, config, null, request.headers, null, resolve, reject, false, request.async);
}
}

function _isEntityNameException(entityName) {
Expand Down
4 changes: 2 additions & 2 deletions dist/dynamics-web-api-callbacks.min.js

Large diffs are not rendered by default.

66 changes: 40 additions & 26 deletions dist/dynamics-web-api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! dynamics-web-api v1.5.12 (c) 2019 Aleksandr Rogov */
/*! dynamics-web-api v1.5.13 (c) 2019 Aleksandr Rogov */
(function webpackUniversalModuleDefinition(root, factory) {
if(typeof exports === 'object' && typeof module === 'object')
module.exports = factory();
Expand Down Expand Up @@ -168,13 +168,13 @@ function generateUUID() { // Public Domain/MIT
}

function getXrmContext() {
if (typeof GetGlobalContext != 'undefined') {
if (typeof GetGlobalContext !== 'undefined') {
return GetGlobalContext();
}
else {
if (typeof Xrm != 'undefined') {
if (typeof Xrm !== 'undefined') {
//d365 v.9.0
if ((!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext))) {
if (!isNull(Xrm.Utility) && !isNull(Xrm.Utility.getGlobalContext)) {
return Xrm.Utility.getGlobalContext();
}
else if (!isNull(Xrm.Page) && !isNull(Xrm.Page.context)) {
Expand Down Expand Up @@ -203,11 +203,11 @@ function initWebApiUrl(version) {

function getXrmInternal() {
//todo: Xrm.Internal namespace is not supported
if (typeof Xrm !== 'undefined') {
return Xrm.Internal;
}
return typeof Xrm !== "undefined" ? Xrm.Internal : null;
}

return null;
function getXrmUtility() {
return typeof Xrm !== "undefined" ? Xrm.Utility : null;
}

var Utility = {
Expand Down Expand Up @@ -249,6 +249,8 @@ var Utility = {

getXrmInternal: getXrmInternal,

getXrmUtility: getXrmUtility,

getClientUrl: getClientUrl,

initWebApiUrl: initWebApiUrl
Expand Down Expand Up @@ -485,7 +487,8 @@ var _entityNames;
*/
function findCollectionName(entityName) {
var xrmInternal = Utility.getXrmInternal();
if (!Utility.isNull(xrmInternal)) {

if (!Utility.isNull(xrmInternal) && typeof xrmInternal.getEntitySetName === "function") {
return xrmInternal.getEntitySetName(entityName) || entityName;
}

Expand All @@ -495,7 +498,7 @@ function findCollectionName(entityName) {
collectionName = _entityNames[entityName];
if (Utility.isNull(collectionName)) {
for (var key in _entityNames) {
if (_entityNames[key] == entityName) {
if (_entityNames[key] === entityName) {
return entityName;
}
}
Expand Down Expand Up @@ -699,26 +702,37 @@ function sendRequest(method, path, config, data, additionalHeaders, responsePara

function _getEntityNames(entityName, config, successCallback, errorCallback) {

var resolve = function (result) {
_entityNames = {};
for (var i = 0; i < result.data.value.length; i++) {
_entityNames[result.data.value[i].LogicalName] = result.data.value[i].LogicalCollectionName;
}
var xrmUtility = Utility.getXrmUtility();

successCallback(findCollectionName(entityName));
};
//try using Xrm.Utility.getEntityMetadata first (because D365 caches metadata)
if (!Utility.isNull(xrmUtility) && typeof xrmUtility.getEntityMetadata === "function") {
xrmUtility.getEntityMetadata(entityName).then(function (response) {
successCallback(response.EntitySetName);
}, errorCallback);
}
else {
//make a web api call for Node.js apps
var resolve = function (result) {
_entityNames = {};
for (var i = 0; i < result.data.value.length; i++) {
_entityNames[result.data.value[i].LogicalName] = result.data.value[i].EntitySetName;
}

var reject = function (error) {
errorCallback({ message: 'Unable to fetch EntityDefinitions. Error: ' + error.message });
};
successCallback(findCollectionName(entityName));
};

var request = RequestConverter.convertRequest({
collection: 'EntityDefinitions',
select: ['LogicalCollectionName', 'LogicalName'],
noCache: true
}, 'retrieveMultiple', config);
var reject = function (error) {
errorCallback({ message: 'Unable to fetch EntityDefinitions. Error: ' + error.message });
};

sendRequest('GET', request.url, config, null, request.headers, null, resolve, reject, false, request.async);
var request = RequestConverter.convertRequest({
collection: 'EntityDefinitions',
select: ['EntitySetName', 'LogicalName'],
noCache: true
}, 'retrieveMultiple', config);

sendRequest('GET', request.url, config, null, request.headers, null, resolve, reject, false, request.async);
}
}

function _isEntityNameException(entityName) {
Expand Down
4 changes: 2 additions & 2 deletions dist/dynamics-web-api.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dynamics-web-api",
"version": "1.5.12",
"version": "1.5.13",
"description": "DynamicsWebApi is a Microsoft Dynamics CRM Web API helper library",
"keywords": [
"crm",
Expand Down

0 comments on commit 0d70184

Please sign in to comment.