Skip to content

Commit c74286e

Browse files
adding inChangeSet property #145
1 parent 443debb commit c74286e

File tree

8 files changed

+53
-32
lines changed

8 files changed

+53
-32
lines changed

dist/dynamics-web-api.cjs.js

Lines changed: 12 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dynamics-web-api.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ export interface BaseRequest {
395395
timeout?: number;
396396
/**The AbortSignal interface represents a signal object that allows you to communicate with a DOM request and abort it if required via an AbortController object. */
397397
signal?: AbortSignal;
398+
/**Indicates if an operation must be included in a Change Set or not. Works in Batch Operations only. By default, it's "true", except for GET operations - they are not allowed in Change Sets. */
399+
inChangeSet?: boolean;
398400
}
399401
export interface Request extends BaseRequest {
400402
/**A name of the Entity Collection or Entity Logical name. */

dist/dynamics-web-api.js

Lines changed: 12 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/dynamics-web-api.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/dynamics-web-api.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,6 +1192,8 @@ export interface BaseRequest {
11921192
timeout?: number;
11931193
/**The AbortSignal interface represents a signal object that allows you to communicate with a DOM request and abort it if required via an AbortController object. */
11941194
signal?: AbortSignal;
1195+
/**Indicates if an operation must be included in a Change Set or not. Works in Batch Operations only. By default, it's "true", except for GET operations - they are not allowed in Change Sets. */
1196+
inChangeSet?: boolean;
11951197
}
11961198

11971199
export interface Request extends BaseRequest {

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export declare namespace Core {
130130
pageNumber?: number;
131131
pagingCookie?: string;
132132
requestId?: string | null;
133+
inChangeSet?: boolean | null;
133134
transferMode?: string;
134135
range?: string;
135136
downloadSize?: string;

src/utils/Request.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,12 @@ export class RequestUtility {
226226
ErrorHelper.boolParameterCheck(request.isBatch, `DynamicsWebApi.${request.functionName}`, "request.isBatch");
227227
}
228228

229+
if (!Utility.isNull(request.inChangeSet)) {
230+
ErrorHelper.boolParameterCheck(request.inChangeSet, `DynamicsWebApi.${request.functionName}`, "request.inChangeSet");
231+
}
232+
233+
if (request.isBatch && Utility.isNull(request.inChangeSet)) request.inChangeSet = true;
234+
229235
if (request.timeout) {
230236
ErrorHelper.numberParameterCheck(request.timeout, `DynamicsWebApi.${request.functionName}`, "request.timeout");
231237
}
@@ -422,9 +428,9 @@ export class RequestUtility {
422428

423429
requests.forEach((internalRequest) => {
424430
internalRequest.functionName = "executeBatch";
425-
const isGet = internalRequest.method === "GET";
431+
const inChangeSet = internalRequest.method === "GET" ? false : !!internalRequest.inChangeSet;
426432

427-
if (isGet && currentChangeSet) {
433+
if (!inChangeSet && currentChangeSet) {
428434
//end current change set
429435
batchBody.push(`\n--${currentChangeSet}--`);
430436

@@ -435,20 +441,20 @@ export class RequestUtility {
435441
if (!currentChangeSet) {
436442
batchBody.push(`\n--${batchBoundary}`);
437443

438-
if (!isGet) {
444+
if (inChangeSet) {
439445
currentChangeSet = `changeset_${Utility.generateUUID()}`;
440446
batchBody.push("Content-Type: multipart/mixed;boundary=" + currentChangeSet);
441447
}
442448
}
443449

444-
if (!isGet) {
450+
if (inChangeSet) {
445451
batchBody.push(`\n--${currentChangeSet}`);
446452
}
447453

448454
batchBody.push("Content-Type: application/http");
449455
batchBody.push("Content-Transfer-Encoding: binary");
450456

451-
if (!isGet) {
457+
if (inChangeSet) {
452458
const contentIdValue = internalRequest.headers.hasOwnProperty("Content-ID") ? internalRequest.headers["Content-ID"] : ++contentId;
453459

454460
batchBody.push(`Content-ID: ${contentIdValue}`);
@@ -460,7 +466,7 @@ export class RequestUtility {
460466
batchBody.push(`\n${internalRequest.method} ${internalRequest.path} HTTP/1.1`);
461467
}
462468

463-
if (isGet) {
469+
if (!inChangeSet) {
464470
batchBody.push("Accept: application/json");
465471
} else {
466472
batchBody.push("Content-Type: application/json");
@@ -474,7 +480,7 @@ export class RequestUtility {
474480

475481
const data = internalRequest.data;
476482

477-
if (!isGet && data) {
483+
if (inChangeSet && data) {
478484
batchBody.push(`\n${RequestUtility.processData(data, config)}`);
479485
}
480486
});

0 commit comments

Comments
 (0)