@manyos/smileconnect-api 1.46.2 → 1.46.4

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.
package/conf/clients.json CHANGED
@@ -240,9 +240,7 @@
240
240
  "basequery": "",
241
241
  "scripts": {
242
242
  "POST": {
243
- "postMapping": [
244
- "reject"
245
- ]
243
+ "postMapping": []
246
244
  }
247
245
  }
248
246
  },
@@ -301,7 +299,7 @@
301
299
  "value": "Other"
302
300
  }
303
301
  ],
304
- "basequery": "",
302
+ "basequery": "1=1",
305
303
  "scripts": {
306
304
  "POST": {
307
305
  "preMapping": [
@@ -120,7 +120,7 @@ async function deleteTaskFlow(rootRequestInstanceId) {
120
120
  async function updateTaskFlow(clientConfig, rootForm, rootRequestId, rootRequestInstanceId) {
121
121
  await deleteTaskFlow(rootRequestInstanceId)
122
122
  let flowBuilderRequest = {
123
- "Parent Name": rootForm,
123
+ "Parent Name": rootRequestId,
124
124
  "ParentID" : rootRequestInstanceId,
125
125
  "Parent Type": "Root Request",
126
126
  "zTmpInternalCommand" : "CREATE",
@@ -133,6 +133,72 @@ async function updateTaskFlow(clientConfig, rootForm, rootRequestId, rootRequest
133
133
 
134
134
  flowBuilderRequest = mappingUtil.applyMapping2Remedy(flowBuilderRequest, mappingflow, clientConfig.flowBuilder.constants);
135
135
  const taskFlowResult = await arquery.createEntry('TMS:FlowBuilder', flowBuilderRequest, clientConfig.options)
136
+ //await activateTaskFlow(clientConfig, rootRequestInstanceId)
137
+ await checkFlowActivation(clientConfig, rootRequestInstanceId, rootRequestId, rootForm)
138
+ }
139
+
140
+ async function checkFlowActivation(clientConfig, rootRequestInstanceId, rootRequestId, rootForm) {
141
+ let subQuery = "'1' = \"rootRequestId\"";
142
+ let statusField = '7'
143
+ let statusReasonField = ''
144
+ let companyField = 'Location Company'
145
+ if (rootForm === CONSTANTS.FORM_WORKORDER) {
146
+ subQuery = `'Work Order ID'=\"${rootRequestId}\"`;
147
+ } else if (rootForm === CONSTANTS.FORM_INCIDENT) {
148
+ subQuery = `'Incident Number'=\"${rootRequestId}\"`;
149
+ } else if (rootForm === CONSTANTS.FORM_PROBLEM) {
150
+ subQuery = `'Problem Investigation ID'=\"${rootRequestId}\"`;
151
+ } else if (rootForm === CONSTANTS.FORM_CHANGE) {
152
+ subQuery = `'Infrastructure Change ID'=\"${rootRequestId}\"`;
153
+ statusField = 'Change Request Status'
154
+ statusReasonField = 'Status Reason'
155
+ }
156
+ //Read instanceId from Root request
157
+ log.debug('Query root request for current status')
158
+ const rootRequest = await arquery.executeARQuery(rootForm, null, subQuery, [statusField, statusReasonField, companyField], clientConfig.options)
159
+ if (rootRequest && rootRequest.data && rootRequest.data.length > 0) {
160
+ const rootRecord = rootRequest.data[0]
161
+ const form = 'TMS:ConfigPhaseManagement'
162
+ log.debug('Query phase config for current phase')
163
+
164
+ let configQuery = `'Activation Status*'="${rootRecord[statusField]}" AND ('Company' = "${rootRecord[companyField]}" OR 'Company' = "- Global -") AND 'AppInstanceFormName' = "${rootForm}" AND 'Status' = "Active"`
165
+ if (rootRecord[statusReasonField]) {
166
+ configQuery = configQuery + ` AND 'Status Reason' = "${rootRecord[statusReasonField]}"`
167
+ } else {
168
+ configQuery = configQuery + ` AND 'Status Reason' = $NULL$`
169
+ }
170
+
171
+
172
+ const phaseRecords = await arquery.executeARQuery(form, undefined,
173
+ configQuery, 'InstanceId')
174
+ if (phaseRecords && phaseRecords.data && phaseRecords.data.length > 0) {
175
+ const phaseRecord = phaseRecords.data[0]
176
+ const phaseGuid = phaseRecord['InstanceId']
177
+ await activateTaskFlow(clientConfig, rootRequestInstanceId, phaseGuid)
178
+ }
179
+ }
180
+
181
+ }
182
+
183
+ async function activateTaskFlow(clientConfig, rootRequestInstanceId, phaseGuid) {
184
+ // Activate flow from here
185
+ const form = 'TMS:Flow'
186
+ const idField = 'Flow ID'
187
+ const flowRequest = {
188
+ "PredecessorStatusReasonSelection": "Success",
189
+ "Predecessor Status" : "Closed",
190
+ "zTmpInternalCommand": "EVALUATE",
191
+ "zTmpInternal" : "True"
192
+ };
193
+
194
+ const records = await arquery.executeARQuery(form, undefined,
195
+ `'RootRequestInstanceID'="${rootRequestInstanceId}" AND 'ParentID' = "${rootRequestInstanceId}" AND 'Predecessor Link' = "Start" AND 'Status' = "Pending" AND 'Sequence Mode' = "Yes" AND 'Phase GUID' = "${phaseGuid}"`, idField)
196
+ if (records && records.data) {
197
+ for (let x=0; x<records.data.length; x++) {
198
+ const record = records.data[x]
199
+ const updateResult = await arquery.updateEntry(form, record[idField], flowRequest)
200
+ }
201
+ }
136
202
  }
137
203
 
138
204
 
package/docs/releases.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  ## API
4
4
 
5
+ ### 1.46.4 - 20.10.21
6
+ Fix known issue: Check for activation Task Phase and activate if reached
7
+
8
+ ### 1.46.3 - 18.10.21
9
+ Fix issue: Task not activated when phase already active
10
+ Known issues: Tasks might get activated early
11
+
5
12
  ### 1.46.2 - 14.10.21
6
13
  Fix issue: Promise Rejection in scripts prevented
7
14
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manyos/smileconnect-api",
3
- "version": "1.46.2",
3
+ "version": "1.46.4",
4
4
  "description": "A proxy and abstraction layer for BMCs IT Service Management Suite",
5
5
  "main": "app.js",
6
6
  "scripts": {