Skip to content

Commit

Permalink
Merge branch 'release/2.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
nsteenbeek committed Dec 22, 2017
2 parents 7833f82 + bc4c57b commit a83b723
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
6 changes: 3 additions & 3 deletions dist/CRMSDK.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/CRMSDK.noBabelPolyfill.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/WebAPI.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/WebAPI.noBabelPolyfill.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "crm-sdk",
"version": "2.2.0",
"version": "2.3.0",
"author": "Dynamics Software <solutions@dynamicssoftware.com> (http://www.dynamicssoftware.com)",
"description": "Javasript Software Development Kit for Microsoft Dynamics CRM Web API",
"main": "dist/CRMSDK.js",
Expand Down
23 changes: 17 additions & 6 deletions src/metadata/Metadata.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,28 @@ class Metadata {
return this.entityDef;
}

static get cachedEntityDefinitionsPromises() {
if (!this.entityDefProms) {
this.entityDefProms = {};
}
return this.entityDefProms;
}

static async getEntityDefinitions(logicalName) {
if (typeof logicalName !== "string") {
throw Error("Invalid logicalName given");
}
if (this.cachedEntityDefinitions[logicalName]) {
return this.cachedEntityDefinitions[logicalName];
}
if (typeof logicalName !== "string") {
throw Error("Invalid logicalName given");
if (!this.cachedEntityDefinitionsPromises[logicalName]) {
this.cachedEntityDefinitionsPromises[logicalName] = WebAPI.retrieveEntitySet("EntityDefinitions", null, `$filter=LogicalName eq '${logicalName}'&$expand=Attributes,ManyToOneRelationships`).then(result => {
const entityDefinitions = result.value[0];
this.cachedEntityDefinitions[logicalName] = entityDefinitions;
return entityDefinitions;
});
}
const result = await WebAPI.retrieveEntitySet("EntityDefinitions", null, `$filter=LogicalName eq '${logicalName}'&$expand=Attributes,ManyToOneRelationships`),
entityDefinitions = result.value[0];
this.cachedEntityDefinitions[logicalName] = entityDefinitions;
return entityDefinitions;
return this.cachedEntityDefinitionsPromises[logicalName];
}

static getCachedEntityDefinitions(logicalName) {
Expand Down

0 comments on commit a83b723

Please sign in to comment.