Skip to content

Commit 6f8f568

Browse files
fixes: on-premise service url issue; incomplete type definitions for typescript, inconsistent removing curly brackets for odata.bind actions.
1 parent 351d879 commit 6f8f568

12 files changed

+51
-26
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ contentId | String | `createRequest`, `updateRequest`, `upsertRequest`, `deleteR
235235
count | Boolean | `retrieveMultipleRequest`, `retrieveAllRequest` | Boolean that sets the $count system query option with a value of true to include a count of entities that match the filter criteria up to 5000 (per page). Do not use $top with $count!
236236
duplicateDetection | Boolean | `createRequest`, `updateRequest`, `upsertRequest` | `v.1.3.4+` **Web API v9+ only!** Boolean that enables duplicate detection. [More Info](https://docs.microsoft.com/en-us/dynamics365/customer-engagement/developer/webapi/update-delete-entities-using-web-api#check-for-duplicate-records)
237237
entity | Object | `createRequest`, `updateRequest`, `upsertRequest` | A JavaScript object with properties corresponding to the logical name of entity attributes (exceptions are lookups and single-valued navigation properties).
238-
expand | Array | `retrieveRequest`, `createRequest`, `updateRequest`, `upsertRequest` | An array of Expand Objects (described below the table) representing the $expand OData System Query Option value to control which related records are also returned.
238+
expand | Array | `retrieveRequest`, `retrieveMultipleRequest`, `createRequest`, `updateRequest`, `upsertRequest` | An array of Expand Objects (described below the table) representing the $expand OData System Query Option value to control which related records are also returned.
239239
filter | String | `retrieveRequest`, `retrieveMultipleRequest`, `retrieveAllRequest` | Use the $filter system query option to set criteria for which entities will be returned.
240240
id | String | `retrieveRequest`, `createRequest`, `updateRequest`, `upsertRequest`, `deleteRequest` | `deprecated in v.1.3.4` Use `key` field, instead of `id`. A String representing the Primary Key (GUID) of the record.
241241
ifmatch | String | `retrieveRequest`, `updateRequest`, `upsertRequest`, `deleteRequest` | Sets If-Match header value that enables to use conditional retrieval or optimistic concurrency in applicable requests. [More Info](https://msdn.microsoft.com/en-us/library/mt607711.aspx)
@@ -268,9 +268,9 @@ property | String | A name of a single-valued navigation property which needs to
268268
select | Array | An Array (of Strings) representing the $select OData System Query Option to control which attributes will be returned.
269269
top | Number | Limit the number of results returned by using the $top system query option.
270270

271-
According to CRM developers ([here](http://stackoverflow.com/a/34742977/2042071) and [here](https://community.dynamics.com/crm/b/joegilldynamicscrm/archive/2016/03/23/web-api-querying-with-expand)
272-
$expand does not work for retrieveMultiple requests which is claimed as a bug of CRM Web API.
273-
As well as multi-level expands are not implemented yet. This situation may be changed with the future updates in the platform. Please look for the news!
271+
The following seems to be fixed: ~~According to CRM developers ([here](http://stackoverflow.com/a/34742977/2042071) and [here](https://community.dynamics.com/crm/b/joegilldynamicscrm/archive/2016/03/23/web-api-querying-with-expand)
272+
$expand does not work for retrieveMultiple requests which is claimed as a bug of CRM Web API.~~
273+
Unconfirmed: Multi-level expands are not implemented yet. This situation may be changed with the future updates in the platform. Please look for the news!
274274

275275
For complex requests to Web API with multi-level expands use `executeFetchXml` function.
276276

dist/dynamics-web-api-callbacks.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,9 +829,16 @@ function stringifyData(data, config) {
829829
}
830830
}
831831

832-
//add full web api url if it's not set
833832
if (!value.startsWith(config.webApiUrl)) {
834-
value = config.webApiUrl + value.replace(/^\\/, '');
833+
//add full web api url if it's not set
834+
if (key.endsWith('@odata.bind')) {
835+
if (!value.startsWith('/')) {
836+
value = '/' + value;
837+
}
838+
}
839+
else {
840+
value = config.webApiUrl + value.replace(/^\//, '');
841+
}
835842
}
836843
}
837844
}
@@ -847,7 +854,7 @@ function stringifyData(data, config) {
847854
});
848855

849856
stringifiedData = stringifiedData.replace(/[\u007F-\uFFFF]/g, function (chr) {
850-
return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4)
857+
return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4);
851858
});
852859
}
853860

@@ -2126,7 +2133,7 @@ function DynamicsWebApi(config) {
21262133
/**
21272134
* Executes a bound Web API action (bound to a particular entity record)
21282135
*
2129-
* @param {string} id - A String representing the GUID value for the record.
2136+
* @param {string} [id] - A String representing the GUID value for the record.
21302137
* @param {string} collection - The name of the Entity Collection or Entity Logical name.
21312138
* @param {string} actionName - The name of the Web API action.
21322139
* @param {Object} [requestObject] - Action request body object.

dist/dynamics-web-api-callbacks.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dynamics-web-api.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -539,9 +539,16 @@ function stringifyData(data, config) {
539539
}
540540
}
541541

542-
//add full web api url if it's not set
543542
if (!value.startsWith(config.webApiUrl)) {
544-
value = config.webApiUrl + value.replace(/^\\/, '');
543+
//add full web api url if it's not set
544+
if (key.endsWith('@odata.bind')) {
545+
if (!value.startsWith('/')) {
546+
value = '/' + value;
547+
}
548+
}
549+
else {
550+
value = config.webApiUrl + value.replace(/^\//, '');
551+
}
545552
}
546553
}
547554
}
@@ -557,7 +564,7 @@ function stringifyData(data, config) {
557564
});
558565

559566
stringifiedData = stringifiedData.replace(/[\u007F-\uFFFF]/g, function (chr) {
560-
return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4)
567+
return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4);
561568
});
562569
}
563570

@@ -1643,7 +1650,7 @@ function DynamicsWebApi(config) {
16431650
/**
16441651
* Executes a bound function
16451652
*
1646-
* @param {string} id - A String representing the GUID value for the record.
1653+
* @param {string} [id] - A String representing the GUID value for the record.
16471654
* @param {string} collection - The name of the Entity Collection or Entity Logical name.
16481655
* @param {string} functionName - The name of the function.
16491656
* @param {Object} [parameters] - Function's input parameters. Example: { param1: "test", param2: 3 }.

dist/dynamics-web-api.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/dynamics-web-api-callbacks.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,7 +1095,7 @@ function DynamicsWebApi(config) {
10951095
/**
10961096
* Executes a bound Web API action (bound to a particular entity record)
10971097
*
1098-
* @param {string} id - A String representing the GUID value for the record.
1098+
* @param {string} [id] - A String representing the GUID value for the record.
10991099
* @param {string} collection - The name of the Entity Collection or Entity Logical name.
11001100
* @param {string} actionName - The name of the Web API action.
11011101
* @param {Object} [requestObject] - Action request body object.

lib/dynamics-web-api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ function DynamicsWebApi(config) {
903903
/**
904904
* Executes a bound function
905905
*
906-
* @param {string} id - A String representing the GUID value for the record.
906+
* @param {string} [id] - A String representing the GUID value for the record.
907907
* @param {string} collection - The name of the Entity Collection or Entity Logical name.
908908
* @param {string} functionName - The name of the function.
909909
* @param {Object} [parameters] - Function's input parameters. Example: { param1: "test", param2: 3 }.

lib/requests/sendRequest.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,16 @@ function stringifyData(data, config) {
6767
}
6868
}
6969

70-
//add full web api url if it's not set
7170
if (!value.startsWith(config.webApiUrl)) {
72-
value = config.webApiUrl + value.replace(/^\\/, '');
71+
//add full web api url if it's not set
72+
if (key.endsWith('@odata.bind')) {
73+
if (!value.startsWith('/')) {
74+
value = '/' + value;
75+
}
76+
}
77+
else {
78+
value = config.webApiUrl + value.replace(/^\//, '');
79+
}
7380
}
7481
}
7582
}
@@ -85,7 +92,7 @@ function stringifyData(data, config) {
8592
});
8693

8794
stringifiedData = stringifiedData.replace(/[\u007F-\uFFFF]/g, function (chr) {
88-
return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4)
95+
return "\\u" + ("0000" + chr.charCodeAt(0).toString(16)).substr(-4);
8996
});
9097
}
9198

tests/main-tests.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,7 +1149,7 @@ describe("promises -", function () {
11491149
.post("/tests_records/$ref", {
11501150
"@odata.id": mocks.webApiUrl + "records(" + mocks.data.testEntityId2 + ")"
11511151
})
1152-
.reply(response.status, response.responseText, response.responseHeaders)
1152+
.reply(response.status, response.responseText, response.responseHeaders);
11531153
});
11541154

11551155
after(function () {
@@ -1604,7 +1604,7 @@ describe("promises -", function () {
16041604
var response = mocks.responses.basicEmptyResponseSuccess;
16051605
scope = nock(mocks.webApiUrl)
16061606
.post("/FUN", mocks.responses.actionRequestModified)
1607-
.reply(response.status, response.responseText, response.responseHeaders)
1607+
.reply(response.status, response.responseText, response.responseHeaders);
16081608
});
16091609

16101610
after(function () {

tests/stubs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ var responseStubs = {
819819
Status: 3,
820820
OpportunityClose: {
821821
subject: "Won Opportunity",
822-
"[email protected]": webApiUrl + "tests(" + dataStubs.testEntityId + ")"
822+
"[email protected]": "/tests(" + dataStubs.testEntityId + ")"
823823
}
824824
},
825825
upsertPreventCreateResponse: {

0 commit comments

Comments
 (0)