@pliancy/salesforce-cpq-sdk 3.8.0 → 3.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -76,14 +76,21 @@ class Quotes {
|
|
|
76
76
|
return this.client.update(query);
|
|
77
77
|
}
|
|
78
78
|
async submitAndApprove(quoteId, comments = '') {
|
|
79
|
+
var _a;
|
|
79
80
|
try {
|
|
80
81
|
const { ApprovalProcess } = require('jsforce/lib/process');
|
|
81
82
|
const approvalProcess = new ApprovalProcess(this.connection);
|
|
82
83
|
const sResult = (await approvalProcess.submit(quoteId, comments, {
|
|
83
84
|
skipEntryCriteria: true,
|
|
84
85
|
}));
|
|
85
|
-
|
|
86
|
-
|
|
86
|
+
// JsForce types say the field is 'newWorkItemIds', but the actual result is 'newWorkitemIds'.
|
|
87
|
+
// Look for the actual API return first, then what the types say it should be, default
|
|
88
|
+
// to empty array.
|
|
89
|
+
const workItemIds = sResult.hasOwnProperty('newWorkitemIds')
|
|
90
|
+
? sResult['newWorkitemIds']
|
|
91
|
+
: (_a = sResult === null || sResult === void 0 ? void 0 : sResult.newWorkItemIds) !== null && _a !== void 0 ? _a : [];
|
|
92
|
+
if (workItemIds && workItemIds.length) {
|
|
93
|
+
const id = workItemIds[0];
|
|
87
94
|
if (!id)
|
|
88
95
|
return { success: false, errors: ['No workItemId returned'] };
|
|
89
96
|
await approvalProcess.approve(id);
|