@manyos/smileconnect-api 1.46.3 → 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 +1 -1
- package/controller/taskController.js +49 -3
- package/docs/releases.md +3 -0
- package/package.json +1 -1
package/conf/clients.json
CHANGED
|
@@ -133,10 +133,55 @@ 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)
|
|
136
|
+
//await activateTaskFlow(clientConfig, rootRequestInstanceId)
|
|
137
|
+
await checkFlowActivation(clientConfig, rootRequestInstanceId, rootRequestId, rootForm)
|
|
137
138
|
}
|
|
138
139
|
|
|
139
|
-
async function
|
|
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
|
|
140
185
|
const form = 'TMS:Flow'
|
|
141
186
|
const idField = 'Flow ID'
|
|
142
187
|
const flowRequest = {
|
|
@@ -145,8 +190,9 @@ async function activateTaskFlow(clientConfig, rootRequestInstanceId) {
|
|
|
145
190
|
"zTmpInternalCommand": "EVALUATE",
|
|
146
191
|
"zTmpInternal" : "True"
|
|
147
192
|
};
|
|
193
|
+
|
|
148
194
|
const records = await arquery.executeARQuery(form, undefined,
|
|
149
|
-
`'RootRequestInstanceID'="${rootRequestInstanceId}" AND 'ParentID' = "${rootRequestInstanceId}" AND 'Predecessor Link' = "Start" AND 'Status' = "Pending" AND 'Sequence Mode' = "Yes"`, idField)
|
|
195
|
+
`'RootRequestInstanceID'="${rootRequestInstanceId}" AND 'ParentID' = "${rootRequestInstanceId}" AND 'Predecessor Link' = "Start" AND 'Status' = "Pending" AND 'Sequence Mode' = "Yes" AND 'Phase GUID' = "${phaseGuid}"`, idField)
|
|
150
196
|
if (records && records.data) {
|
|
151
197
|
for (let x=0; x<records.data.length; x++) {
|
|
152
198
|
const record = records.data[x]
|
package/docs/releases.md
CHANGED