@manyos/smileconnect-api 1.38.1 → 1.39.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.
- package/app.js +9 -0
- package/conf/clients.json +1 -2
- package/conf/scripts/checkGlobalParams.js +3 -0
- package/controller/cmdbobjectController.js +21 -21
- package/controller/customFormController.js +19 -19
- package/controller/relatedObjectsController.js +5 -5
- package/controller/scriptController.js +9 -8
- package/controller/taskController.js +31 -30
- package/controller/ticketController.js +18 -24
- package/controller/ticketWorkLogController.js +11 -11
- package/package.json +1 -1
- package/routes/cmdbObjectRoutes.js +7 -7
- package/routes/customFormRoutes.js +5 -5
- package/routes/taskRoutes.js +11 -11
- package/routes/ticketRoutes.js +5 -5
- package/routes/ticketWorkLogRoutes.js +4 -4
package/app.js
CHANGED
|
@@ -233,6 +233,15 @@ app.get('/debug', function (req, res, next) {
|
|
|
233
233
|
//global authentication
|
|
234
234
|
app.use(passport.authenticate('jwt', {session: false}), responseHandler.logRequest);
|
|
235
235
|
|
|
236
|
+
//set globalscript params
|
|
237
|
+
app.use(function (req, res, next) {
|
|
238
|
+
req.globalScriptParams = {
|
|
239
|
+
query: req.query,
|
|
240
|
+
params: req.params
|
|
241
|
+
}
|
|
242
|
+
next()
|
|
243
|
+
});
|
|
244
|
+
|
|
236
245
|
// setup routes
|
|
237
246
|
|
|
238
247
|
app.use('/v1/cmdbobjects', function(req, res, next) {
|
package/conf/clients.json
CHANGED
|
@@ -21,7 +21,7 @@ function getRandomId() {
|
|
|
21
21
|
return v4();
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
function getCmdbObjects(config, category, ciIds, includeString, options) {
|
|
24
|
+
function getCmdbObjects(config, category, ciIds, includeString, options, globalScriptParams) {
|
|
25
25
|
let query = '1=1';
|
|
26
26
|
if (category)
|
|
27
27
|
query = `'Category' = \"${category}\"`;
|
|
@@ -37,7 +37,7 @@ function getCmdbObjects(config, category, ciIds, includeString, options) {
|
|
|
37
37
|
query = query + ciQuery + ')';
|
|
38
38
|
log.error('query', query);
|
|
39
39
|
}
|
|
40
|
-
return queryCMDBObject(config, query, null, options, includeString);
|
|
40
|
+
return queryCMDBObject(config, query, null, options, includeString, undefined, globalScriptParams);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
function getCIRelations(clientConfig, id) {
|
|
@@ -121,7 +121,7 @@ function getSchemaName(classId) {
|
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
123
|
|
|
124
|
-
function queryCMDBObject(clientConfig, query, customFields, customOptions, includeString, mapping) {
|
|
124
|
+
function queryCMDBObject(clientConfig, query, customFields, customOptions, includeString, mapping, globalScriptParams) {
|
|
125
125
|
let fields = clientConfig.cmdbobject.fields;
|
|
126
126
|
let deleteClassId = false;
|
|
127
127
|
|
|
@@ -158,7 +158,7 @@ function queryCMDBObject(clientConfig, query, customFields, customOptions, inclu
|
|
|
158
158
|
if (result && result.data && result.data.length) {
|
|
159
159
|
let x = 0;
|
|
160
160
|
for (x=0; x< result.data.length; x++) {
|
|
161
|
-
const cmdbObject = await handleCMDBObjectResult(result.data[x], mapping, clientConfig, includeArray, globalRelationObjects, deleteClassId);
|
|
161
|
+
const cmdbObject = await handleCMDBObjectResult(result.data[x], mapping, clientConfig, includeArray, globalRelationObjects, deleteClassId, globalScriptParams);
|
|
162
162
|
cmdbObjects.push(cmdbObject);
|
|
163
163
|
}
|
|
164
164
|
}
|
|
@@ -170,7 +170,7 @@ function queryCMDBObject(clientConfig, query, customFields, customOptions, inclu
|
|
|
170
170
|
});
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
async function handleCMDBObjectResult(cmdbObject, mapping, clientConfig, includeArray, globalRelationObjects, deleteClassId) {
|
|
173
|
+
async function handleCMDBObjectResult(cmdbObject, mapping, clientConfig, includeArray, globalRelationObjects, deleteClassId, globalScriptParams) {
|
|
174
174
|
//get class form
|
|
175
175
|
const classId = cmdbObject['Class Id'];
|
|
176
176
|
if (deleteClassId === true) {
|
|
@@ -182,7 +182,7 @@ async function handleCMDBObjectResult(cmdbObject, mapping, clientConfig, include
|
|
|
182
182
|
|
|
183
183
|
//run preScripts
|
|
184
184
|
if (scripts && scripts.preMapping) {
|
|
185
|
-
await scriptController.runScripts(scripts.preMapping, cmdbObject, clientConfig.clientId);
|
|
185
|
+
await scriptController.runScripts(scripts.preMapping, cmdbObject, clientConfig.clientId, globalScriptParams);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
//Apply mapping
|
|
@@ -236,7 +236,7 @@ async function handleCMDBObjectResult(cmdbObject, mapping, clientConfig, include
|
|
|
236
236
|
|
|
237
237
|
//run preScripts
|
|
238
238
|
if (scripts && scripts.postMapping) {
|
|
239
|
-
await scriptController.runScripts(scripts.postMapping, cmdbObject, clientConfig.clientId);
|
|
239
|
+
await scriptController.runScripts(scripts.postMapping, cmdbObject, clientConfig.clientId, globalScriptParams);
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
return cmdbObject;
|
|
@@ -272,9 +272,9 @@ async function getCMDBObjectClassAttributes(id, classId, clientConfig, mapping)
|
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
async function getCmdbObject(config, id, includeString, mapping) {
|
|
275
|
+
async function getCmdbObject(config, id, includeString, mapping, globalScriptParams) {
|
|
276
276
|
const query = `'Instance Id'=\"${id}\"`;
|
|
277
|
-
const returnValue = await queryCMDBObject(config, query, null, null, includeString, mapping);
|
|
277
|
+
const returnValue = await queryCMDBObject(config, query, null, null, includeString, mapping, globalScriptParams);
|
|
278
278
|
log.debug (returnValue);
|
|
279
279
|
const cmdbObject = returnValue.data[0];
|
|
280
280
|
return {data: cmdbObject, included: returnValue.included};
|
|
@@ -293,20 +293,20 @@ async function applyMapping(clientConfig, data) {
|
|
|
293
293
|
return mappedRecord;
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
function searchCmdbObjectByName(config, name, includeString) {
|
|
296
|
+
function searchCmdbObjectByName(config, name, includeString, globalScriptParams) {
|
|
297
297
|
const query = `'Name'LIKE\"%${name}%\"`;
|
|
298
|
-
return queryCMDBObject(config, query, null, null, includeString);
|
|
298
|
+
return queryCMDBObject(config, query, null, null, includeString, globalScriptParams);
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
function searchCmdbObject(clientConfig, searchString, fields, options, includeString) {
|
|
301
|
+
function searchCmdbObject(clientConfig, searchString, fields, options, includeString, globalScriptParams) {
|
|
302
302
|
const mapping = config.getMapping(CMDBOBJECT);
|
|
303
303
|
const mappedString = searchUtil.applyMapping(searchString, mapping);
|
|
304
304
|
const customFields = searchUtil.getCustomFields(clientConfig.cmdbobject.fields, mapping, fields);
|
|
305
305
|
options.sort = searchUtil.applySortMapping(options.sort, mapping);
|
|
306
|
-
return queryCMDBObject(clientConfig, mappedString, customFields, options, includeString);
|
|
306
|
+
return queryCMDBObject(clientConfig, mappedString, customFields, options, includeString, undefined, globalScriptParams);
|
|
307
307
|
}
|
|
308
308
|
|
|
309
|
-
async function updateCmdbObject(ticketConfig, clientConfig, id, ciData, classId) {
|
|
309
|
+
async function updateCmdbObject(ticketConfig, clientConfig, id, ciData, classId, globalScriptParams) {
|
|
310
310
|
const formName = classId || 'AST:BaseElement';
|
|
311
311
|
|
|
312
312
|
const scripts = clientConfig[CMDBOBJECT].scripts.PUT;
|
|
@@ -314,7 +314,7 @@ async function updateCmdbObject(ticketConfig, clientConfig, id, ciData, classId)
|
|
|
314
314
|
|
|
315
315
|
//run preScripts
|
|
316
316
|
if (scripts && scripts.preMapping) {
|
|
317
|
-
await scriptController.runScripts(scripts.preMapping, ciData, clientConfig.clientId);
|
|
317
|
+
await scriptController.runScripts(scripts.preMapping, ciData, clientConfig.clientId, globalScriptParams);
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
const myClientConfig = {};
|
|
@@ -338,14 +338,14 @@ async function updateCmdbObject(ticketConfig, clientConfig, id, ciData, classId)
|
|
|
338
338
|
|
|
339
339
|
//run postMapping
|
|
340
340
|
if (scripts && scripts.postMapping) {
|
|
341
|
-
await scriptController.runScripts(scripts.postMapping, ciData, clientConfig.clientId);
|
|
341
|
+
await scriptController.runScripts(scripts.postMapping, ciData, clientConfig.clientId, globalScriptParams);
|
|
342
342
|
}
|
|
343
343
|
|
|
344
344
|
const update = await arquery.updateEntry(formName, ci['Request ID'], ciData);
|
|
345
345
|
|
|
346
346
|
//run afterExecution
|
|
347
347
|
if (scripts && scripts.afterExecution) {
|
|
348
|
-
await scriptController.runScripts(scripts.afterExecution, ciData, clientConfig.clientId);
|
|
348
|
+
await scriptController.runScripts(scripts.afterExecution, ciData, clientConfig.clientId, globalScriptParams);
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
return update;
|
|
@@ -371,7 +371,7 @@ function getClassMapping(classId) {
|
|
|
371
371
|
return mappings;
|
|
372
372
|
}
|
|
373
373
|
|
|
374
|
-
async function createCmdbObject(assetConfig, clientConfig, classId, ciData) {
|
|
374
|
+
async function createCmdbObject(assetConfig, clientConfig, classId, ciData, globalScriptParams) {
|
|
375
375
|
const reconId = getRandomId();
|
|
376
376
|
const instanceId = getRandomId();
|
|
377
377
|
|
|
@@ -380,7 +380,7 @@ async function createCmdbObject(assetConfig, clientConfig, classId, ciData) {
|
|
|
380
380
|
|
|
381
381
|
//run preScripts
|
|
382
382
|
if (scripts && scripts.preMapping) {
|
|
383
|
-
await scriptController.runScripts(scripts.preMapping, ciData, clientConfig.clientId);
|
|
383
|
+
await scriptController.runScripts(scripts.preMapping, ciData, clientConfig.clientId, globalScriptParams);
|
|
384
384
|
}
|
|
385
385
|
|
|
386
386
|
const mapping = getClassMapping(classId);
|
|
@@ -392,7 +392,7 @@ async function createCmdbObject(assetConfig, clientConfig, classId, ciData) {
|
|
|
392
392
|
|
|
393
393
|
//run postMapping
|
|
394
394
|
if (scripts && scripts.postMapping) {
|
|
395
|
-
await scriptController.runScripts(scripts.postMapping, ciData, clientConfig.clientId);
|
|
395
|
+
await scriptController.runScripts(scripts.postMapping, ciData, clientConfig.clientId, globalScriptParams);
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
ciData['Data Set Id'] = "BMC.ASSET"
|
|
@@ -403,7 +403,7 @@ async function createCmdbObject(assetConfig, clientConfig, classId, ciData) {
|
|
|
403
403
|
|
|
404
404
|
//run afterExecution
|
|
405
405
|
if (scripts && scripts.afterExecution) {
|
|
406
|
-
await scriptController.runScripts(scripts.afterExecution, ciData, clientConfig.clientId);
|
|
406
|
+
await scriptController.runScripts(scripts.afterExecution, ciData, clientConfig.clientId, globalScriptParams);
|
|
407
407
|
}
|
|
408
408
|
|
|
409
409
|
return instanceId;
|
|
@@ -12,12 +12,12 @@ const mappingUtil = require('../util/mappingUtil');
|
|
|
12
12
|
|
|
13
13
|
const ticketCache = new CacheService(process.env.CACHETTL_TICKETS || 1); // Create a new cache service instance
|
|
14
14
|
|
|
15
|
-
function getRecords(formConfig, clientConfig, includeString, customOptions) {
|
|
15
|
+
function getRecords(formConfig, clientConfig, includeString, customOptions, globalScriptParams) {
|
|
16
16
|
let query = '1=1';
|
|
17
|
-
return queryRecords(formConfig, clientConfig, query, null, null, customOptions, includeString);
|
|
17
|
+
return queryRecords(formConfig, clientConfig, query, null, null, customOptions, includeString, globalScriptParams);
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
async function createRecord(formConfig, clientConfig, data) {
|
|
20
|
+
async function createRecord(formConfig, clientConfig, data, globalScriptParams) {
|
|
21
21
|
const allScripts = clientConfig[formConfig.configName].scripts;
|
|
22
22
|
let scripts
|
|
23
23
|
if (allScripts) {
|
|
@@ -26,7 +26,7 @@ async function createRecord(formConfig, clientConfig, data) {
|
|
|
26
26
|
|
|
27
27
|
//run preScripts
|
|
28
28
|
if (scripts && scripts.preMapping) {
|
|
29
|
-
await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId);
|
|
29
|
+
await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId, globalScriptParams);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
const requestType = formConfig.requestType;
|
|
@@ -40,7 +40,7 @@ async function createRecord(formConfig, clientConfig, data) {
|
|
|
40
40
|
|
|
41
41
|
//run postScripts
|
|
42
42
|
if (scripts && scripts.postMapping) {
|
|
43
|
-
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId);
|
|
43
|
+
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId, globalScriptParams);
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
const result = await arquery.createEntry(formConfig.formName, data, clientConfig.options)
|
|
@@ -58,12 +58,12 @@ async function createRecord(formConfig, clientConfig, data) {
|
|
|
58
58
|
|
|
59
59
|
//run afterExecution
|
|
60
60
|
if (scripts && scripts.afterExecution) {
|
|
61
|
-
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId);
|
|
61
|
+
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId, globalScriptParams);
|
|
62
62
|
}
|
|
63
63
|
return recordCreateId;
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
function queryRecords(formConfig, clientConfig, query, mapping, customFields, customOptions, includeString) {
|
|
66
|
+
function queryRecords(formConfig, clientConfig, query, mapping, customFields, customOptions, includeString, globalScriptParams) {
|
|
67
67
|
const includeArray = getIncludeArray(includeString);
|
|
68
68
|
log.debug('Get config for', formConfig.configName)
|
|
69
69
|
let fields = clientConfig[formConfig.configName].fields;
|
|
@@ -94,7 +94,7 @@ function queryRecords(formConfig, clientConfig, query, mapping, customFields, cu
|
|
|
94
94
|
if (result && result.data && result.data.length) {
|
|
95
95
|
let x = 0;
|
|
96
96
|
for (x=0; x< result.data.length; x++) {
|
|
97
|
-
const ticket = await handleRecord(formConfig, result.data[x], mapping, clientConfig, includeArray);
|
|
97
|
+
const ticket = await handleRecord(formConfig, result.data[x], mapping, clientConfig, includeArray, globalScriptParams);
|
|
98
98
|
records.push(ticket);
|
|
99
99
|
}
|
|
100
100
|
}
|
|
@@ -105,7 +105,7 @@ function queryRecords(formConfig, clientConfig, query, mapping, customFields, cu
|
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
async function handleRecord(formConfig, record, mapping, clientConfig, includeArray,
|
|
108
|
+
async function handleRecord(formConfig, record, mapping, clientConfig, includeArray, globalScriptParams) {
|
|
109
109
|
const allScripts = clientConfig[formConfig.configName].scripts;
|
|
110
110
|
let scripts = [];
|
|
111
111
|
if (allScripts) {
|
|
@@ -117,7 +117,7 @@ async function handleRecord(formConfig, record, mapping, clientConfig, includeAr
|
|
|
117
117
|
const preScripts = scripts.preMapping;
|
|
118
118
|
try {
|
|
119
119
|
for (let x = 0; x < preScripts.length; x++) {
|
|
120
|
-
const result = await scriptController.executeScript(preScripts[x], record, null, clientConfig.clientId);
|
|
120
|
+
const result = await scriptController.executeScript(preScripts[x], record, null, clientConfig.clientId, globalScriptParams);
|
|
121
121
|
}
|
|
122
122
|
} catch (error) {
|
|
123
123
|
throw error;
|
|
@@ -131,7 +131,7 @@ async function handleRecord(formConfig, record, mapping, clientConfig, includeAr
|
|
|
131
131
|
const postScripts = scripts.postMapping;
|
|
132
132
|
try {
|
|
133
133
|
for (let x = 0; x < postScripts.length; x++) {
|
|
134
|
-
const result = await scriptController.executeScript(postScripts[x], record, null, clientConfig.clientId);
|
|
134
|
+
const result = await scriptController.executeScript(postScripts[x], record, null, clientConfig.clientId, globalScriptParams);
|
|
135
135
|
}
|
|
136
136
|
} catch (error) {
|
|
137
137
|
throw error;
|
|
@@ -140,14 +140,14 @@ async function handleRecord(formConfig, record, mapping, clientConfig, includeAr
|
|
|
140
140
|
return record;
|
|
141
141
|
}
|
|
142
142
|
|
|
143
|
-
async function getRecord(formConfig, clientConfig, id, mapping, includeString) {
|
|
143
|
+
async function getRecord(formConfig, clientConfig, id, mapping, includeString, globalScriptParams) {
|
|
144
144
|
const query = `'1'=\"${id}\"`;
|
|
145
|
-
const returnValue = await queryRecords(formConfig, clientConfig, query, mapping, null, null, includeString);
|
|
145
|
+
const returnValue = await queryRecords(formConfig, clientConfig, query, mapping, null, null, includeString, globalScriptParams);
|
|
146
146
|
const record = returnValue.data[0];
|
|
147
147
|
return {data: record};
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
async function updateRecord(formConfig, clientConfig, id, recordData) {
|
|
150
|
+
async function updateRecord(formConfig, clientConfig, id, recordData, globalScriptParams) {
|
|
151
151
|
const allScripts = clientConfig[formConfig.configName].scripts;
|
|
152
152
|
let scripts
|
|
153
153
|
if (allScripts) {
|
|
@@ -157,7 +157,7 @@ async function updateRecord(formConfig, clientConfig, id, recordData) {
|
|
|
157
157
|
|
|
158
158
|
//run preScripts
|
|
159
159
|
if (scripts && scripts.preMapping) {
|
|
160
|
-
await scriptController.runScripts(scripts.preMapping, recordData, clientConfig.clientId);
|
|
160
|
+
await scriptController.runScripts(scripts.preMapping, recordData, clientConfig.clientId, globalScriptParams);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
163
|
const mapping = config.getMapping(formConfig.configName);
|
|
@@ -166,25 +166,25 @@ async function updateRecord(formConfig, clientConfig, id, recordData) {
|
|
|
166
166
|
|
|
167
167
|
//run postMapping
|
|
168
168
|
if (scripts && scripts.postMapping) {
|
|
169
|
-
await scriptController.runScripts(scripts.postMapping, recordData, clientConfig.clientId);
|
|
169
|
+
await scriptController.runScripts(scripts.postMapping, recordData, clientConfig.clientId, globalScriptParams);
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
const update = await arquery.updateEntry(formConfig.formName, id, recordData);
|
|
173
173
|
|
|
174
174
|
//run afterExecution
|
|
175
175
|
if (scripts && scripts.afterExecution) {
|
|
176
|
-
await scriptController.runScripts(scripts.afterExecution, recordData, clientConfig.clientId);
|
|
176
|
+
await scriptController.runScripts(scripts.afterExecution, recordData, clientConfig.clientId, globalScriptParams);
|
|
177
177
|
}
|
|
178
178
|
|
|
179
179
|
return update;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
|
-
function searchRecords(formConfig, clientConfig, searchString, fields, options, includeString) {
|
|
182
|
+
function searchRecords(formConfig, clientConfig, searchString, fields, options, includeString, globalScriptParams) {
|
|
183
183
|
const mapping = config.getMapping(formConfig.configName);
|
|
184
184
|
const mappedString = searchUtil.applyMapping(searchString, mapping);
|
|
185
185
|
const customFields = searchUtil.getCustomFields(clientConfig[formConfig.configName].fields, mapping, fields);
|
|
186
186
|
options.sort = searchUtil.applySortMapping(options.sort, mapping);
|
|
187
|
-
return queryRecords(formConfig, clientConfig, mappedString, null, customFields, options, includeString);
|
|
187
|
+
return queryRecords(formConfig, clientConfig, mappedString, null, customFields, options, includeString, globalScriptParams);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
module.exports = {
|
|
@@ -72,7 +72,7 @@ async function getRelatedObjects(req, res, next) {
|
|
|
72
72
|
for (x=0; x < cmdbObjectArray.length; x++) {
|
|
73
73
|
const ciId = cmdbObjectArray[x];
|
|
74
74
|
log.debug('searchCMDBObject', ciId);
|
|
75
|
-
const cmdbObject = await cmdbObjectController.getCmdbObject(clientConfig, ciId);
|
|
75
|
+
const cmdbObject = await cmdbObjectController.getCmdbObject(clientConfig, ciId, undefined, undefined, req.globalScriptParams);
|
|
76
76
|
if (cmdbObjects !== null && cmdbObjects !== undefined && cmdbObject && cmdbObject.data) {
|
|
77
77
|
cmdbObjects.push(cmdbObject.data);
|
|
78
78
|
}
|
|
@@ -88,7 +88,7 @@ async function getRelatedObjects(req, res, next) {
|
|
|
88
88
|
const id = incidentArray[x];
|
|
89
89
|
log.debug('searchIncident', id);
|
|
90
90
|
const ticketConfig = config.ticketConfig["incidents"];
|
|
91
|
-
const result = await ticketController.getTicket(ticketConfig, clientConfig, id);
|
|
91
|
+
const result = await ticketController.getTicket(ticketConfig, clientConfig, id, undefined, undefined, req.globalScriptParams);
|
|
92
92
|
if (result && result.data) {
|
|
93
93
|
incidents.push(result.data);
|
|
94
94
|
}
|
|
@@ -104,7 +104,7 @@ async function getRelatedObjects(req, res, next) {
|
|
|
104
104
|
const id = ticketIdArray[x];
|
|
105
105
|
log.debug('searchWorkOrder', id);
|
|
106
106
|
const ticketConfig = config.ticketConfig["workorders"];
|
|
107
|
-
const result = await ticketController.getTicket(ticketConfig, clientConfig, id)
|
|
107
|
+
const result = await ticketController.getTicket(ticketConfig, clientConfig, id, undefined, undefined, req.globalScriptParams)
|
|
108
108
|
if (result && result.data) {
|
|
109
109
|
tickets.push(result.data);
|
|
110
110
|
}
|
|
@@ -120,7 +120,7 @@ async function getRelatedObjects(req, res, next) {
|
|
|
120
120
|
const id = ticketIdArray[x];
|
|
121
121
|
log.debug('searchProblem', id);
|
|
122
122
|
const ticketConfig = config.ticketConfig["problems"];
|
|
123
|
-
const result = await ticketController.getTicket(ticketConfig, clientConfig, id)
|
|
123
|
+
const result = await ticketController.getTicket(ticketConfig, clientConfig, id, undefined, undefined, req.globalScriptParams)
|
|
124
124
|
if (result && result.data) {
|
|
125
125
|
tickets.push(result.data);
|
|
126
126
|
}
|
|
@@ -136,7 +136,7 @@ async function getRelatedObjects(req, res, next) {
|
|
|
136
136
|
const id = ticketIdArray[x];
|
|
137
137
|
log.debug('searchChange', id);
|
|
138
138
|
const ticketConfig = config.ticketConfig["changes"];
|
|
139
|
-
const result = await ticketController.getTicket(ticketConfig, clientConfig, id)
|
|
139
|
+
const result = await ticketController.getTicket(ticketConfig, clientConfig, id, undefined, undefined, req.globalScriptParams)
|
|
140
140
|
if (result && result.data) {
|
|
141
141
|
tickets.push(result.data);
|
|
142
142
|
}
|
|
@@ -45,7 +45,7 @@ function recFindByExt(base,ext,files,result) {
|
|
|
45
45
|
return result
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
async function executeScriptInternal(scriptId, requestData, params, executedByScript, clientId) {
|
|
48
|
+
async function executeScriptInternal(scriptId, requestData, params, executedByScript, clientId, globalScriptParams) {
|
|
49
49
|
|
|
50
50
|
const code = await getGlobalScript(scriptId);
|
|
51
51
|
|
|
@@ -53,14 +53,14 @@ async function executeScriptInternal(scriptId, requestData, params, executedBySc
|
|
|
53
53
|
throw (`Script ${scriptId} does not exist!`);
|
|
54
54
|
}
|
|
55
55
|
|
|
56
|
-
return executeCode(code, requestData, params, null, executedByScript, clientId, scriptId);
|
|
56
|
+
return executeCode(code, requestData, params, null, executedByScript, clientId, scriptId, globalScriptParams);
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
async function executeScript(scriptId, requestData, params, clientId) {
|
|
60
|
-
return executeScriptInternal(scriptId, requestData, params, false, clientId)
|
|
59
|
+
async function executeScript(scriptId, requestData, params, clientId, globalScriptParams) {
|
|
60
|
+
return executeScriptInternal(scriptId, requestData, params, false, clientId, globalScriptParams)
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
async function executeCode(code, requestData, params, logStream, executedByScript, clientId, scriptId) {
|
|
63
|
+
async function executeCode(code, requestData, params, logStream, executedByScript, clientId, scriptId, globalScriptParams) {
|
|
64
64
|
const log = require('@manyos/logger').setupLog('SMILEcatalog_Script_' + scriptId);
|
|
65
65
|
//todo should only be added once
|
|
66
66
|
/*if (logStream) {
|
|
@@ -70,7 +70,7 @@ async function executeCode(code, requestData, params, logStream, executedByScrip
|
|
|
70
70
|
//try to set user data for sandbox
|
|
71
71
|
|
|
72
72
|
async function executeScriptByScript(scriptId, requestData, params) {
|
|
73
|
-
return executeScriptInternal(scriptId, requestData, params, true, clientId)
|
|
73
|
+
return executeScriptInternal(scriptId, requestData, params, true, clientId, globalScriptParams)
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
const sandbox = {
|
|
@@ -80,6 +80,7 @@ async function executeCode(code, requestData, params, logStream, executedByScrip
|
|
|
80
80
|
log,
|
|
81
81
|
clientId,
|
|
82
82
|
script:executeScriptByScript,
|
|
83
|
+
globalScriptParams,
|
|
83
84
|
env: process.env,
|
|
84
85
|
fetch:fetch
|
|
85
86
|
};
|
|
@@ -245,10 +246,10 @@ async function getGlobalScripts() {
|
|
|
245
246
|
return getScripts(path);
|
|
246
247
|
}
|
|
247
248
|
|
|
248
|
-
async function runScripts(scripts, data, clientId) {
|
|
249
|
+
async function runScripts(scripts, data, clientId, globalScriptParams) {
|
|
249
250
|
try {
|
|
250
251
|
for (let x = 0; x < scripts.length; x++) {
|
|
251
|
-
await executeScript(scripts[x], data, undefined, clientId);
|
|
252
|
+
await executeScript(scripts[x], data, undefined, clientId, globalScriptParams);
|
|
252
253
|
}
|
|
253
254
|
} catch (error) {
|
|
254
255
|
throw error;
|
|
@@ -11,19 +11,19 @@ const scriptController = require('./scriptController');
|
|
|
11
11
|
|
|
12
12
|
const taskCache = new CacheService(process.env.CACHETTL_TASK || 0); // Create a new cache service instance
|
|
13
13
|
|
|
14
|
-
function getTasks(config, category) {
|
|
14
|
+
function getTasks(config, category, globalScriptParams) {
|
|
15
15
|
let query = '1=1';
|
|
16
16
|
if (category)
|
|
17
17
|
query = `'Category' = \"${category}\"`;
|
|
18
|
-
return queryTasks(config, query);
|
|
18
|
+
return queryTasks(config, query, globalScriptParams);
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
function getTasksByRootRequest(config, rootRequestId, rootRequestForm) {
|
|
21
|
+
function getTasksByRootRequest(config, rootRequestId, rootRequestForm, globalScriptParams) {
|
|
22
22
|
const query = `'RootRequestID' = \"${rootRequestId}\" AND 'RootRequestFormName' = \"${rootRequestForm}\"`;
|
|
23
|
-
return queryTasks(config, query);
|
|
23
|
+
return queryTasks(config, query, globalScriptParams);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
async function createTask(clientConfig, rootForm, rootRequestId, taskData, createTaskFlow) {
|
|
26
|
+
async function createTask(clientConfig, rootForm, rootRequestId, taskData, createTaskFlow, globalScriptParams) {
|
|
27
27
|
const scripts = clientConfig.task.scripts.POST;
|
|
28
28
|
const fields = clientConfig.task.fields;
|
|
29
29
|
|
|
@@ -70,21 +70,21 @@ async function createTask(clientConfig, rootForm, rootRequestId, taskData, creat
|
|
|
70
70
|
|
|
71
71
|
//run preScripts
|
|
72
72
|
if (scripts && scripts.preMapping) {
|
|
73
|
-
await scriptController.runScripts(scripts.preMapping, taskData, clientConfig.clientId);
|
|
73
|
+
await scriptController.runScripts(scripts.preMapping, taskData, clientConfig.clientId, globalScriptParams);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
taskData = mappingUtil.applyMapping2Remedy(taskData, mapping, clientConfig.task.constants, fields);
|
|
77
77
|
|
|
78
78
|
//run postScripts
|
|
79
79
|
if (scripts && scripts.postMapping) {
|
|
80
|
-
await scriptController.runScripts(scripts.postMapping, taskData, clientConfig.clientId);
|
|
80
|
+
await scriptController.runScripts(scripts.postMapping, taskData, clientConfig.clientId, globalScriptParams);
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
const taskResult = await arquery.createEntry('TMS:Task', taskData, clientConfig.options)
|
|
84
84
|
|
|
85
85
|
//run afterExecution
|
|
86
86
|
if (scripts && scripts.afterExecution) {
|
|
87
|
-
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId);
|
|
87
|
+
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId, globalScriptParams);
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
log.debug('Create Task Result', taskResult);
|
|
@@ -113,7 +113,7 @@ async function createTask(clientConfig, rootForm, rootRequestId, taskData, creat
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
//Todo make dynamic
|
|
116
|
-
async function createWorklog(clientConfig, taskId, summary, text, attachment) {
|
|
116
|
+
async function createWorklog(clientConfig, taskId, summary, text, attachment, globalScriptParams) {
|
|
117
117
|
const task = await getTask(clientConfig,taskId)
|
|
118
118
|
const fields = clientConfig.taskWorklog.fields;
|
|
119
119
|
|
|
@@ -140,28 +140,28 @@ async function createWorklog(clientConfig, taskId, summary, text, attachment) {
|
|
|
140
140
|
|
|
141
141
|
//run preScripts
|
|
142
142
|
if (scripts && scripts.preMapping) {
|
|
143
|
-
await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId);
|
|
143
|
+
await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId, globalScriptParams);
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
data = mappingUtil.applyMapping2Remedy(data, mapping, clientConfig.taskWorklog.constants, fields);
|
|
147
147
|
|
|
148
148
|
//run postScripts
|
|
149
149
|
if (scripts && scripts.postMapping) {
|
|
150
|
-
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId);
|
|
150
|
+
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId, globalScriptParams);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
153
|
const result = await arquery.createEntry('TMS:WorkInfo', data, clientConfig.options)
|
|
154
154
|
|
|
155
155
|
//run afterExecution
|
|
156
156
|
if (scripts && scripts.afterExecution) {
|
|
157
|
-
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId);
|
|
157
|
+
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId, globalScriptParams);
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
return(result);
|
|
161
161
|
//todo add attachment handling
|
|
162
162
|
}
|
|
163
163
|
|
|
164
|
-
function queryTasks(clientConfig, query) {
|
|
164
|
+
function queryTasks(clientConfig, query, globalScriptParams) {
|
|
165
165
|
const scripts = clientConfig.task.scripts.GET;
|
|
166
166
|
|
|
167
167
|
const key = clientConfig.task.basequery + clientConfig.task.fields.toString() + query;
|
|
@@ -196,7 +196,7 @@ function queryTasks(clientConfig, query) {
|
|
|
196
196
|
|
|
197
197
|
//run preScripts
|
|
198
198
|
if (scripts && scripts.preMapping) {
|
|
199
|
-
await scriptController.runScripts(scripts.preMapping, element, clientConfig.clientId);
|
|
199
|
+
await scriptController.runScripts(scripts.preMapping, element, clientConfig.clientId, globalScriptParams);
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
//Apply mapping
|
|
@@ -212,7 +212,7 @@ function queryTasks(clientConfig, query) {
|
|
|
212
212
|
|
|
213
213
|
//run preScripts
|
|
214
214
|
if (scripts && scripts.postMapping) {
|
|
215
|
-
await scriptController.runScripts(scripts.postMapping, element, clientConfig.clientId);
|
|
215
|
+
await scriptController.runScripts(scripts.postMapping, element, clientConfig.clientId, globalScriptParams);
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
return ({
|
|
@@ -229,7 +229,7 @@ function queryTasks(clientConfig, query) {
|
|
|
229
229
|
})
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
async function queryWorklogs(clientConfig, query, mapping) {
|
|
232
|
+
async function queryWorklogs(clientConfig, query, mapping, globalScriptParams) {
|
|
233
233
|
|
|
234
234
|
const scripts = clientConfig.taskWorklog.scripts.GET;
|
|
235
235
|
|
|
@@ -252,7 +252,7 @@ async function queryWorklogs(clientConfig, query, mapping) {
|
|
|
252
252
|
|
|
253
253
|
//run preScripts
|
|
254
254
|
if (scripts && scripts.preMapping) {
|
|
255
|
-
await scriptController.runScripts(scripts.preMapping, element, clientConfig.clientId);
|
|
255
|
+
await scriptController.runScripts(scripts.preMapping, element, clientConfig.clientId, globalScriptParams);
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
//Apply mapping
|
|
@@ -268,7 +268,7 @@ async function queryWorklogs(clientConfig, query, mapping) {
|
|
|
268
268
|
|
|
269
269
|
//run postScripts
|
|
270
270
|
if (scripts && scripts.postMapping) {
|
|
271
|
-
await scriptController.runScripts(scripts.postMapping, element, clientConfig.clientId);
|
|
271
|
+
await scriptController.runScripts(scripts.postMapping, element, clientConfig.clientId, globalScriptParams);
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
return {
|
|
@@ -280,33 +280,34 @@ async function queryWorklogs(clientConfig, query, mapping) {
|
|
|
280
280
|
});
|
|
281
281
|
}
|
|
282
282
|
|
|
283
|
-
async function getTask(clientConfig, id) {
|
|
283
|
+
async function getTask(clientConfig, id, globalScriptParams) {
|
|
284
284
|
const query = `'Task ID'=\"${id}\"`;
|
|
285
|
-
const tasks = await queryTasks(clientConfig, query);
|
|
285
|
+
const tasks = await queryTasks(clientConfig, query, globalScriptParams);
|
|
286
286
|
return tasks.data[0];
|
|
287
287
|
}
|
|
288
288
|
|
|
289
|
-
async function getTaskByRootRequest(config, rootRequestId, taskId) {
|
|
289
|
+
async function getTaskByRootRequest(config, rootRequestId, taskId, globalScriptParams) {
|
|
290
290
|
const query = `'Task ID'=\"${taskId}\" AND 'RootRequestID' = \"${rootRequestId}\"`;
|
|
291
|
-
const returnValue = await queryTasks(config, query);
|
|
291
|
+
const returnValue = await queryTasks(config, query, globalScriptParams);
|
|
292
292
|
const task = returnValue.data[0];
|
|
293
293
|
return {data: task, included: returnValue.included};
|
|
294
294
|
}
|
|
295
295
|
|
|
296
|
-
function getTaskWorklogs(config, taskId) {
|
|
296
|
+
function getTaskWorklogs(config, taskId, globalScriptParams) {
|
|
297
297
|
const query = `'TaskOrTaskGroupID'=\"${taskId}\"`;
|
|
298
|
-
return queryWorklogs(config, query);
|
|
298
|
+
return queryWorklogs(config, query, undefined, globalScriptParams);
|
|
299
299
|
}
|
|
300
300
|
|
|
301
|
-
|
|
301
|
+
//todo add scripts an
|
|
302
|
+
async function getTaskWorklog(config, taskId, worklogId, globalScriptParams) {
|
|
302
303
|
const query = `'TaskOrTaskGroupID'=\"${taskId}\" AND 'Work Info ID'=\"${worklogId}\"`;
|
|
303
|
-
const returnValue = await queryWorklogs(config, query);
|
|
304
|
+
const returnValue = await queryWorklogs(config, query, undefined, globalScriptParams);
|
|
304
305
|
log.debug ('rtn', returnValue);
|
|
305
306
|
const worklog = returnValue.data[0];
|
|
306
307
|
return {data: worklog, included: returnValue.included};
|
|
307
308
|
}
|
|
308
309
|
|
|
309
|
-
async function updateTask(clientConfig, id, taskData) {
|
|
310
|
+
async function updateTask(clientConfig, id, taskData, globalScriptParams) {
|
|
310
311
|
const mapping = config.getMapping('task');
|
|
311
312
|
const taskConstants = clientConfig.task.constants;
|
|
312
313
|
const scripts = clientConfig.task.scripts.PUT;
|
|
@@ -314,21 +315,21 @@ async function updateTask(clientConfig, id, taskData) {
|
|
|
314
315
|
|
|
315
316
|
//run preScripts
|
|
316
317
|
if (scripts && scripts.preMapping) {
|
|
317
|
-
await scriptController.runScripts(scripts.preMapping, taskData, clientConfig.clientId);
|
|
318
|
+
await scriptController.runScripts(scripts.preMapping, taskData, clientConfig.clientId, globalScriptParams);
|
|
318
319
|
}
|
|
319
320
|
|
|
320
321
|
taskData = mappingUtil.applyMapping2Remedy(taskData, mapping, taskConstants, fields);
|
|
321
322
|
|
|
322
323
|
//run postScripts
|
|
323
324
|
if (scripts && scripts.postMapping) {
|
|
324
|
-
await scriptController.runScripts(scripts.postMapping, taskData, clientConfig.clientId);
|
|
325
|
+
await scriptController.runScripts(scripts.postMapping, taskData, clientConfig.clientId, globalScriptParams);
|
|
325
326
|
}
|
|
326
327
|
|
|
327
328
|
const result = await arquery.updateEntry('TMS:Task', id, taskData);
|
|
328
329
|
|
|
329
330
|
//run afterExecution
|
|
330
331
|
if (scripts && scripts.afterExecution) {
|
|
331
|
-
await scriptController.runScripts(scripts.afterExecution, taskData, clientConfig.clientId);
|
|
332
|
+
await scriptController.runScripts(scripts.afterExecution, taskData, clientConfig.clientId, globalScriptParams);
|
|
332
333
|
}
|
|
333
334
|
return result;
|
|
334
335
|
}
|
|
@@ -14,12 +14,12 @@ const mappingUtil = require('../util/mappingUtil');
|
|
|
14
14
|
|
|
15
15
|
const ticketCache = new CacheService(process.env.CACHETTL_TICKETS || 1); // Create a new cache service instance
|
|
16
16
|
|
|
17
|
-
function getTickets(ticketConfig, config, includeString, customOptions) {
|
|
17
|
+
function getTickets(ticketConfig, config, includeString, customOptions, globalScriptParams) {
|
|
18
18
|
let query = '1=1';
|
|
19
|
-
return queryTickets(ticketConfig, config, query, null, null, customOptions, includeString);
|
|
19
|
+
return queryTickets(ticketConfig, config, query, null, null, customOptions, includeString, globalScriptParams);
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
async function createTicket(ticketConfig, clientConfig, data) {
|
|
22
|
+
async function createTicket(ticketConfig, clientConfig, data, globalScriptParams) {
|
|
23
23
|
const scripts = clientConfig[ticketConfig.requestType].scripts.POST;
|
|
24
24
|
|
|
25
25
|
//run preScripts
|
|
@@ -39,7 +39,7 @@ async function createTicket(ticketConfig, clientConfig, data) {
|
|
|
39
39
|
|
|
40
40
|
//run postScripts
|
|
41
41
|
if (scripts && scripts.postMapping) {
|
|
42
|
-
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId);
|
|
42
|
+
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId, globalScriptParams);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
const result = await arquery.createEntry(ticketConfig.forms.new, data, clientConfig.options)
|
|
@@ -50,12 +50,6 @@ async function createTicket(ticketConfig, clientConfig, data) {
|
|
|
50
50
|
const resultInterfaceCreate = await arquery.executeARQuery(ticketConfig.forms.new, null, "'1'=\"" + ticketCreateId + "\"", ticketConfig.ticketIdField, clientConfig.options)
|
|
51
51
|
if (resultInterfaceCreate.data && Array.isArray(resultInterfaceCreate.data) && resultInterfaceCreate.data.length && resultInterfaceCreate.data[0][ticketConfig.ticketIdField]) {
|
|
52
52
|
const ticketId = resultInterfaceCreate.data[0][ticketConfig.ticketIdField];
|
|
53
|
-
//todo fix create worklog
|
|
54
|
-
/*createWorklog(clientConfig, ticketId, 'Created', 'Incident ' + CONSTANTS.TEXT_CREATED_BY, false).then(function (worklogResult) {
|
|
55
|
-
log.debug('Worklog', worklogResult);
|
|
56
|
-
}).catch(function (error) {
|
|
57
|
-
log.error('HPD:Worklog creation error', error)
|
|
58
|
-
});*/
|
|
59
53
|
} else {
|
|
60
54
|
log.error('Cannot create Ticket', resultInterfaceCreate);
|
|
61
55
|
throw({message: 'Cannot create Ticket', details : resultInterfaceCreate});
|
|
@@ -63,12 +57,12 @@ async function createTicket(ticketConfig, clientConfig, data) {
|
|
|
63
57
|
|
|
64
58
|
//run afterExecution
|
|
65
59
|
if (scripts && scripts.afterExecution) {
|
|
66
|
-
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId);
|
|
60
|
+
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId, globalScriptParams);
|
|
67
61
|
}
|
|
68
62
|
return resultInterfaceCreate;
|
|
69
63
|
}
|
|
70
64
|
|
|
71
|
-
function queryTickets(ticketConfig, clientConfig, query, mapping, customFields, customOptions, includeString) {
|
|
65
|
+
function queryTickets(ticketConfig, clientConfig, query, mapping, customFields, customOptions, includeString, globalScriptParams) {
|
|
72
66
|
log.debug('config', ticketConfig);
|
|
73
67
|
const includeArray = getIncludeArray(includeString);
|
|
74
68
|
log.debug('ticketConfig.requestType', ticketConfig.requestType);
|
|
@@ -101,7 +95,7 @@ function queryTickets(ticketConfig, clientConfig, query, mapping, customFields,
|
|
|
101
95
|
if (result && result.data && result.data.length) {
|
|
102
96
|
let x = 0;
|
|
103
97
|
for (x=0; x< result.data.length; x++) {
|
|
104
|
-
const ticket = await handleTicket(ticketConfig, result.data[x], mapping, clientConfig, includeArray, globalRelationObjects);
|
|
98
|
+
const ticket = await handleTicket(ticketConfig, result.data[x], mapping, clientConfig, includeArray, globalRelationObjects, globalScriptParams);
|
|
105
99
|
tickets.push(ticket);
|
|
106
100
|
}
|
|
107
101
|
}
|
|
@@ -113,7 +107,7 @@ function queryTickets(ticketConfig, clientConfig, query, mapping, customFields,
|
|
|
113
107
|
});
|
|
114
108
|
}
|
|
115
109
|
|
|
116
|
-
async function handleTicket(ticketConfig, ticket, mapping, clientConfig, includeArray, globalRelationObjects) {
|
|
110
|
+
async function handleTicket(ticketConfig, ticket, mapping, clientConfig, includeArray, globalRelationObjects, globalScriptParams) {
|
|
117
111
|
const allScripts = clientConfig[ticketConfig.requestType].scripts;
|
|
118
112
|
let scripts = [];
|
|
119
113
|
if (allScripts) {
|
|
@@ -136,7 +130,7 @@ async function handleTicket(ticketConfig, ticket, mapping, clientConfig, include
|
|
|
136
130
|
const preScripts = scripts.preMapping;
|
|
137
131
|
try {
|
|
138
132
|
for (let x = 0; x < preScripts.length; x++) {
|
|
139
|
-
const result = await scriptController.executeScript(preScripts[x], ticket, null, clientConfig.clientId);
|
|
133
|
+
const result = await scriptController.executeScript(preScripts[x], ticket, null, clientConfig.clientId, globalScriptParams);
|
|
140
134
|
}
|
|
141
135
|
} catch (error) {
|
|
142
136
|
throw error;
|
|
@@ -160,7 +154,7 @@ async function handleTicket(ticketConfig, ticket, mapping, clientConfig, include
|
|
|
160
154
|
const postScripts = scripts.postMapping;
|
|
161
155
|
try {
|
|
162
156
|
for (let x = 0; x < postScripts.length; x++) {
|
|
163
|
-
const result = await scriptController.executeScript(postScripts[x], ticket, null, clientConfig.clientId);
|
|
157
|
+
const result = await scriptController.executeScript(postScripts[x], ticket, null, clientConfig.clientId, globalScriptParams);
|
|
164
158
|
}
|
|
165
159
|
} catch (error) {
|
|
166
160
|
throw error;
|
|
@@ -260,7 +254,7 @@ function checkFieldsProblem(problem, globalRelationObjects) {
|
|
|
260
254
|
}
|
|
261
255
|
|
|
262
256
|
|
|
263
|
-
async function getTicket(ticketConfig, config, id, mapping, includeString) {
|
|
257
|
+
async function getTicket(ticketConfig, config, id, mapping, includeString, globalScriptParams) {
|
|
264
258
|
let query = '1=2';
|
|
265
259
|
const requestType = ticketConfig.requestType;
|
|
266
260
|
if (requestType === 'incident') {
|
|
@@ -272,18 +266,18 @@ async function getTicket(ticketConfig, config, id, mapping, includeString) {
|
|
|
272
266
|
} else if (requestType === 'workOrder') {
|
|
273
267
|
query = `'Work Order ID'=\"${id}\"`;
|
|
274
268
|
}
|
|
275
|
-
const returnValue = await queryTickets(ticketConfig, config, query, mapping, null, null, includeString);
|
|
269
|
+
const returnValue = await queryTickets(ticketConfig, config, query, mapping, null, null, includeString, globalScriptParams);
|
|
276
270
|
const ticket = returnValue.data[0];
|
|
277
271
|
return {data: ticket, included: returnValue.included};
|
|
278
272
|
}
|
|
279
273
|
|
|
280
|
-
async function updateTicket(ticketConfig, clientConfig, id, ticketData) {
|
|
274
|
+
async function updateTicket(ticketConfig, clientConfig, id, ticketData, globalScriptParams) {
|
|
281
275
|
const scripts = clientConfig[ticketConfig.requestType].scripts.PUT;
|
|
282
276
|
const fields = clientConfig[ticketConfig.requestType].fields
|
|
283
277
|
|
|
284
278
|
//run preScripts
|
|
285
279
|
if (scripts && scripts.preMapping) {
|
|
286
|
-
await scriptController.runScripts(scripts.preMapping, ticketData, clientConfig.clientId);
|
|
280
|
+
await scriptController.runScripts(scripts.preMapping, ticketData, clientConfig.clientId, globalScriptParams);
|
|
287
281
|
}
|
|
288
282
|
|
|
289
283
|
log.debug(clientConfig[ticketConfig.requestType]);
|
|
@@ -298,10 +292,10 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData) {
|
|
|
298
292
|
|
|
299
293
|
//run postMapping
|
|
300
294
|
if (scripts && scripts.postMapping) {
|
|
301
|
-
await scriptController.runScripts(scripts.postMapping, ticketData, clientConfig.clientId);
|
|
295
|
+
await scriptController.runScripts(scripts.postMapping, ticketData, clientConfig.clientId, globalScriptParams);
|
|
302
296
|
}
|
|
303
297
|
|
|
304
|
-
const ticket = await getTicket(ticketConfig, myClientConfig, id, myMapping);
|
|
298
|
+
const ticket = await getTicket(ticketConfig, myClientConfig, id, myMapping, undefined, globalScriptParams);
|
|
305
299
|
log.debug('Ticket to Update', ticket);
|
|
306
300
|
//todo Abfangen wenn getTicket nichts liefert.
|
|
307
301
|
const update = await arquery.updateEntry(ticketConfig.forms.regular, ticket.data.internalId, ticketData);
|
|
@@ -314,12 +308,12 @@ async function updateTicket(ticketConfig, clientConfig, id, ticketData) {
|
|
|
314
308
|
return update;
|
|
315
309
|
}
|
|
316
310
|
|
|
317
|
-
function searchTicket(ticketConfig, clientConfig, searchString, fields, options, includeString) {
|
|
311
|
+
function searchTicket(ticketConfig, clientConfig, searchString, fields, options, includeString, globalScriptParams) {
|
|
318
312
|
const mapping = config.getMapping(ticketConfig.requestType);
|
|
319
313
|
const mappedString = searchUtil.applyMapping(searchString, mapping);
|
|
320
314
|
const customFields = searchUtil.getCustomFields(clientConfig[ticketConfig.requestType].fields, mapping, fields);
|
|
321
315
|
options.sort = searchUtil.applySortMapping(options.sort, mapping);
|
|
322
|
-
return queryTickets(ticketConfig, clientConfig, mappedString, null, customFields, options, includeString);
|
|
316
|
+
return queryTickets(ticketConfig, clientConfig, mappedString, null, customFields, options, includeString, globalScriptParams);
|
|
323
317
|
}
|
|
324
318
|
|
|
325
319
|
module.exports = {
|
|
@@ -11,7 +11,7 @@ const scriptController = require('./scriptController');
|
|
|
11
11
|
|
|
12
12
|
const ticketCache = new CacheService(process.env.CACHETTL_TICKETS || 1); // Create a new cache service instance
|
|
13
13
|
|
|
14
|
-
async function createWorklog(ticketConfig, clientConfig, ticketId, summary, text, isPublic) {
|
|
14
|
+
async function createWorklog(ticketConfig, clientConfig, ticketId, summary, text, isPublic, globalScriptParams) {
|
|
15
15
|
const scripts = clientConfig[ticketConfig.requestTypeWorkLog].scripts.POST;
|
|
16
16
|
const mapping = config.getMapping(ticketConfig.requestTypeWorkLog);
|
|
17
17
|
const fields = clientConfig[ticketConfig.requestTypeWorkLog].fields;
|
|
@@ -61,21 +61,21 @@ async function createWorklog(ticketConfig, clientConfig, ticketId, summary, text
|
|
|
61
61
|
|
|
62
62
|
//run preScripts
|
|
63
63
|
if (scripts && scripts.preMapping) {
|
|
64
|
-
await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId);
|
|
64
|
+
await scriptController.runScripts(scripts.preMapping, data, clientConfig.clientId, globalScriptParams);
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
data = mappingUtil.applyMapping2Remedy(data, mapping, clientConstants, fields);
|
|
68
68
|
|
|
69
69
|
//run postScripts
|
|
70
70
|
if (scripts && scripts.postMapping) {
|
|
71
|
-
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId);
|
|
71
|
+
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId, globalScriptParams);
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const result = arquery.createEntry(ticketConfig.forms.workLog, data, clientConfig.options)
|
|
75
75
|
|
|
76
76
|
//run afterExecution
|
|
77
77
|
if (scripts && scripts.afterExecution) {
|
|
78
|
-
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId);
|
|
78
|
+
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId, globalScriptParams);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
return result;
|
|
@@ -102,7 +102,7 @@ function getAttachmentFieldId(attachmentId) {
|
|
|
102
102
|
return attachmentFieldId;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
async function getWorklogs(ticketConfig, clientConfig, ticketId, mapping) {
|
|
105
|
+
async function getWorklogs(ticketConfig, clientConfig, ticketId, mapping, globalScriptParams) {
|
|
106
106
|
let query = '1=2';
|
|
107
107
|
const requestType = ticketConfig.requestType;
|
|
108
108
|
if (requestType === 'incident') {
|
|
@@ -114,11 +114,11 @@ async function getWorklogs(ticketConfig, clientConfig, ticketId, mapping) {
|
|
|
114
114
|
} else if (requestType === 'workOrder') {
|
|
115
115
|
query = `'Work Order ID'=\"${ticketId}\"`;
|
|
116
116
|
}
|
|
117
|
-
const returnValue = await queryWorklogs(ticketConfig, clientConfig, query, mapping);
|
|
117
|
+
const returnValue = await queryWorklogs(ticketConfig, clientConfig, query, mapping, globalScriptParams);
|
|
118
118
|
return {data: returnValue.data};
|
|
119
119
|
}
|
|
120
120
|
|
|
121
|
-
async function getWorklog(ticketConfig, clientConfig, ticketId, worklogId, mapping) {
|
|
121
|
+
async function getWorklog(ticketConfig, clientConfig, ticketId, worklogId, mapping, globalScriptParams) {
|
|
122
122
|
let query = '1=2';
|
|
123
123
|
const requestType = ticketConfig.requestType;
|
|
124
124
|
if (requestType === 'incident') {
|
|
@@ -130,7 +130,7 @@ async function getWorklog(ticketConfig, clientConfig, ticketId, worklogId, mappi
|
|
|
130
130
|
} else if (requestType === 'workOrder') {
|
|
131
131
|
query = `'Work Order ID'=\"${ticketId}\" AND '1' = \"${worklogId}\"`;
|
|
132
132
|
}
|
|
133
|
-
const returnValue = await queryWorklogs(ticketConfig, clientConfig, query, mapping);
|
|
133
|
+
const returnValue = await queryWorklogs(ticketConfig, clientConfig, query, mapping, globalScriptParams);
|
|
134
134
|
const urls = {
|
|
135
135
|
"attachmentUrl":
|
|
136
136
|
`${ticketConfig.baseURI}/${ticketId}/worklogs/${worklogId}/attachments/1`
|
|
@@ -147,7 +147,7 @@ async function getWorklog(ticketConfig, clientConfig, ticketId, worklogId, mappi
|
|
|
147
147
|
return {data: returnValue.data[0], urls};
|
|
148
148
|
}
|
|
149
149
|
|
|
150
|
-
async function queryWorklogs(ticketConfig, clientConfig, query, mapping) {
|
|
150
|
+
async function queryWorklogs(ticketConfig, clientConfig, query, mapping, globalScriptParams) {
|
|
151
151
|
const baseQuery = clientConfig[ticketConfig.requestTypeWorkLog].basequery;
|
|
152
152
|
const fields = clientConfig[ticketConfig.requestTypeWorkLog].fields;
|
|
153
153
|
const key = 'worklog' + baseQuery + fields.toString() + query;
|
|
@@ -169,12 +169,12 @@ async function queryWorklogs(ticketConfig, clientConfig, query, mapping) {
|
|
|
169
169
|
const element = result.data[x];
|
|
170
170
|
//run preScripts
|
|
171
171
|
if (scripts && scripts.preMapping) {
|
|
172
|
-
await scriptController.runScripts(scripts.preMapping, result.data, clientConfig.clientId);
|
|
172
|
+
await scriptController.runScripts(scripts.preMapping, result.data, clientConfig.clientId, globalScriptParams);
|
|
173
173
|
}
|
|
174
174
|
applyMapping(element, mapping, 'Entry ID');
|
|
175
175
|
//run postScripts
|
|
176
176
|
if (scripts && scripts.postMapping) {
|
|
177
|
-
await scriptController.runScripts(scripts.postMapping, result.data, clientConfig.clientId);
|
|
177
|
+
await scriptController.runScripts(scripts.postMapping, result.data, clientConfig.clientId, globalScriptParams);
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
180
|
return {
|
package/package.json
CHANGED
|
@@ -59,7 +59,7 @@ module.exports = (function () {
|
|
|
59
59
|
if (!valResult.isEmpty()) {
|
|
60
60
|
next(valResult.array());
|
|
61
61
|
} else {
|
|
62
|
-
cmdbobjects.searchCmdbObject(req.user.config, req.body.searchString, req.body.fields, options, includeString).then(function (result) {
|
|
62
|
+
cmdbobjects.searchCmdbObject(req.user.config, req.body.searchString, req.body.fields, options, includeString, req.globalScriptParams).then(function (result) {
|
|
63
63
|
log.debug('result', result);
|
|
64
64
|
req.includeObjectsList = result.included;
|
|
65
65
|
req.result = {data:result.data || []};
|
|
@@ -94,7 +94,7 @@ module.exports = (function () {
|
|
|
94
94
|
options.offset = Number.parseInt(offset);
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
cmdbobjects.getCmdbObjects(req.user.config, category, ciIds, includeString, options).then(function (result) {
|
|
97
|
+
cmdbobjects.getCmdbObjects(req.user.config, category, ciIds, includeString, options, req.globalScriptParams).then(function (result) {
|
|
98
98
|
log.debug('result', result);
|
|
99
99
|
req.includeObjectsList = result.included;
|
|
100
100
|
req.result = {data:result.data || []};
|
|
@@ -115,7 +115,7 @@ module.exports = (function () {
|
|
|
115
115
|
CONSTANTS.FORM_ASSET,
|
|
116
116
|
id
|
|
117
117
|
);
|
|
118
|
-
cmdbobjects.getCmdbObject(req.user.config, id, includeString).then(function (result) {
|
|
118
|
+
cmdbobjects.getCmdbObject(req.user.config, id, includeString, undefined, req.globalScriptParams).then(function (result) {
|
|
119
119
|
log.debug('result', result);
|
|
120
120
|
req.includeObjectsList = result.included;
|
|
121
121
|
req.result = {data:result.data || {}};
|
|
@@ -183,8 +183,8 @@ module.exports = (function () {
|
|
|
183
183
|
const ci = req.body.data;
|
|
184
184
|
const hasAccess = await cmdbobjects.hasAccess(req.user.config, id);
|
|
185
185
|
if (hasAccess) {
|
|
186
|
-
const result = await cmdbobjects.updateCmdbObject(req.ticketConfig, req.user.config, id, req.body.data, classId);
|
|
187
|
-
const ci = await cmdbobjects.getCmdbObject(req.user.config, id, includeString);
|
|
186
|
+
const result = await cmdbobjects.updateCmdbObject(req.ticketConfig, req.user.config, id, req.body.data, classId, req.globalScriptParams);
|
|
187
|
+
const ci = await cmdbobjects.getCmdbObject(req.user.config, id, includeString, undefined, req.globalScriptParams);
|
|
188
188
|
req.result = ci;
|
|
189
189
|
next();
|
|
190
190
|
} else {
|
|
@@ -214,8 +214,8 @@ module.exports = (function () {
|
|
|
214
214
|
//const clientConfig = config.getClientConfig(clientId);
|
|
215
215
|
const result = [];
|
|
216
216
|
try {
|
|
217
|
-
const ciInstanceId = await cmdbobjects.createCmdbObject(req.ticketConfig, req.user.config, classId, req.body.data);
|
|
218
|
-
const ci = await cmdbobjects.getCmdbObject(req.user.config, ciInstanceId, includeString);
|
|
217
|
+
const ciInstanceId = await cmdbobjects.createCmdbObject(req.ticketConfig, req.user.config, classId, req.body.data, req.globalScriptParams);
|
|
218
|
+
const ci = await cmdbobjects.getCmdbObject(req.user.config, ciInstanceId, includeString, undefined, req.globalScriptParams);
|
|
219
219
|
req.result = ci;
|
|
220
220
|
next();
|
|
221
221
|
} catch (e) {
|
|
@@ -33,7 +33,7 @@ module.exports = (function() {
|
|
|
33
33
|
options.offset = Number.parseInt(offset);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
customFormController.getRecords(req.formConfig, req.user.config, includeString, options).then(function (result) {
|
|
36
|
+
customFormController.getRecords(req.formConfig, req.user.config, includeString, options, globalScriptParams).then(function (result) {
|
|
37
37
|
log.debug('result', result);
|
|
38
38
|
req.result = {data:result.data};
|
|
39
39
|
next();
|
|
@@ -59,7 +59,7 @@ module.exports = (function() {
|
|
|
59
59
|
req.errorStatus = 422;
|
|
60
60
|
next(errors.array());
|
|
61
61
|
} else {
|
|
62
|
-
customFormController.createRecord(req.formConfig, req.user.config, req.body.data).then(async function (createResult) {
|
|
62
|
+
customFormController.createRecord(req.formConfig, req.user.config, req.body.data, globalScriptParams).then(async function (createResult) {
|
|
63
63
|
const recordId = createResult;
|
|
64
64
|
eventLog.setTicketId(req, recordId);
|
|
65
65
|
req.eventData.ticketNumber = recordId;
|
|
@@ -104,7 +104,7 @@ module.exports = (function() {
|
|
|
104
104
|
if (!valResult.isEmpty()) {
|
|
105
105
|
next(valResult.array());
|
|
106
106
|
} else {
|
|
107
|
-
customFormController.searchRecords(req.formConfig, req.user.config, req.body.searchString, req.body.fields, options, includeString).then(function (result) {
|
|
107
|
+
customFormController.searchRecords(req.formConfig, req.user.config, req.body.searchString, req.body.fields, options, includeString, globalScriptParams).then(function (result) {
|
|
108
108
|
log.debug('result', result);
|
|
109
109
|
req.result = {data:result.data};
|
|
110
110
|
next();
|
|
@@ -130,7 +130,7 @@ module.exports = (function() {
|
|
|
130
130
|
});
|
|
131
131
|
|
|
132
132
|
function getRecord(req, res, next, clientConfig, id, mapping, includeString) {
|
|
133
|
-
customFormController.getRecord(req.formConfig, clientConfig, id, mapping, includeString).then(function (result) {
|
|
133
|
+
customFormController.getRecord(req.formConfig, clientConfig, id, mapping, includeString, globalScriptParams).then(function (result) {
|
|
134
134
|
log.debug('result', result);
|
|
135
135
|
req.includeObjectsList = result.included;
|
|
136
136
|
req.result = {data:result.data || {}};
|
|
@@ -160,7 +160,7 @@ module.exports = (function() {
|
|
|
160
160
|
req.errorStatus = 422;
|
|
161
161
|
next(errors.array());
|
|
162
162
|
} else {
|
|
163
|
-
customFormController.updateRecord(req.formConfig, req.user.config, id, req.body.data)
|
|
163
|
+
customFormController.updateRecord(req.formConfig, req.user.config, id, req.body.data, globalScriptParams)
|
|
164
164
|
.then(async function (updateResult) {
|
|
165
165
|
getRecord(req, res, next, req.user.config, id, null, includeString);
|
|
166
166
|
}).catch(function (reason) {
|
package/routes/taskRoutes.js
CHANGED
|
@@ -24,7 +24,7 @@ module.exports = (function () {
|
|
|
24
24
|
id
|
|
25
25
|
);
|
|
26
26
|
|
|
27
|
-
const result = await task.getTasksByRootRequest(req.user.config, id, req.parentForm);
|
|
27
|
+
const result = await task.getTasksByRootRequest(req.user.config, id, req.parentForm, req.globalScriptParams);
|
|
28
28
|
req.includeObjectsList = result.included;
|
|
29
29
|
req.result = {data:result.data || {}};
|
|
30
30
|
|
|
@@ -50,7 +50,7 @@ module.exports = (function () {
|
|
|
50
50
|
if (req.query.createTaskFlow && req.query.createTaskFlow.toLowerCase() === 'false') {
|
|
51
51
|
createTaskFlow = false;
|
|
52
52
|
}
|
|
53
|
-
task.createTask(req.user.config, req.parentForm, req.parentId, req.body.data, createTaskFlow).then(async function (createResult) {
|
|
53
|
+
task.createTask(req.user.config, req.parentForm, req.parentId, req.body.data, createTaskFlow, req.globalScriptParams).then(async function (createResult) {
|
|
54
54
|
log.debug('createResult', createResult);
|
|
55
55
|
const resultKeys = Object.keys(createResult);
|
|
56
56
|
let taskResult = {};
|
|
@@ -59,7 +59,7 @@ module.exports = (function () {
|
|
|
59
59
|
let x=0;
|
|
60
60
|
for (x=0; x<resultKeys.length; x++) {
|
|
61
61
|
const taskId = createResult[resultKeys[x]];
|
|
62
|
-
const result = await task.getTaskByRootRequest(req.user.config, req.parentId, taskId);
|
|
62
|
+
const result = await task.getTaskByRootRequest(req.user.config, req.parentId, taskId, req.globalScriptParams);
|
|
63
63
|
taskResult.push(result.data);
|
|
64
64
|
}
|
|
65
65
|
//todo fix included objects
|
|
@@ -68,7 +68,7 @@ module.exports = (function () {
|
|
|
68
68
|
next();
|
|
69
69
|
} else {
|
|
70
70
|
const taskId = createResult['0'];
|
|
71
|
-
task.getTaskByRootRequest(req.user.config, req.parentId, taskId).then(function (result) {
|
|
71
|
+
task.getTaskByRootRequest(req.user.config, req.parentId, taskId, req.globalScriptParams).then(function (result) {
|
|
72
72
|
req.includeObjectsList = result.included;
|
|
73
73
|
req.result = {data:result.data || {}};
|
|
74
74
|
next();
|
|
@@ -95,7 +95,7 @@ module.exports = (function () {
|
|
|
95
95
|
taskId
|
|
96
96
|
);
|
|
97
97
|
|
|
98
|
-
const result = await task.getTaskByRootRequest(req.user.config, parentId, taskId);
|
|
98
|
+
const result = await task.getTaskByRootRequest(req.user.config, parentId, taskId, req.globalScriptParams);
|
|
99
99
|
req.includeObjectsList = result.included;
|
|
100
100
|
req.result = {data:result.data || {}};
|
|
101
101
|
next();
|
|
@@ -118,8 +118,8 @@ module.exports = (function () {
|
|
|
118
118
|
req.errorStatus = 422;
|
|
119
119
|
next(errors.array());
|
|
120
120
|
} else {
|
|
121
|
-
task.updateTask(req.user.config, taskId, req.body.data).then(function (updateResult) {
|
|
122
|
-
task.getTaskByRootRequest(req.user.config, req.parentId, taskId).then(function (result) {
|
|
121
|
+
task.updateTask(req.user.config, taskId, req.body.data, req.globalScriptParams).then(function (updateResult) {
|
|
122
|
+
task.getTaskByRootRequest(req.user.config, req.parentId, taskId, req.globalScriptParams).then(function (result) {
|
|
123
123
|
req.includeObjectsList = result.included;
|
|
124
124
|
req.result = {data:result.data || {}};
|
|
125
125
|
next();
|
|
@@ -144,7 +144,7 @@ module.exports = (function () {
|
|
|
144
144
|
taskId
|
|
145
145
|
);
|
|
146
146
|
|
|
147
|
-
const result = await task.getTaskWorklogs(req.user.config, taskId);
|
|
147
|
+
const result = await task.getTaskWorklogs(req.user.config, taskId, req.globalScriptParams);
|
|
148
148
|
req.includeObjectsList = result.included;
|
|
149
149
|
req.result = {data:result.data || {}};
|
|
150
150
|
next();
|
|
@@ -173,10 +173,10 @@ module.exports = (function () {
|
|
|
173
173
|
req.errorStatus = 422;
|
|
174
174
|
next(errors.array());
|
|
175
175
|
} else {
|
|
176
|
-
task.createWorklog(req.user.config, taskId, req.body.data.summary, req.body.data.text)
|
|
176
|
+
task.createWorklog(req.user.config, taskId, req.body.data.summary, req.body.data.text, undefined, req.globalScriptParams)
|
|
177
177
|
.then(createResult => {
|
|
178
178
|
const worklogId = createResult['0'];
|
|
179
|
-
task.getTaskWorklog(req.user.config, taskId, worklogId).then(result => {
|
|
179
|
+
task.getTaskWorklog(req.user.config, taskId, worklogId, req.globalScriptParams).then(result => {
|
|
180
180
|
const urls = {
|
|
181
181
|
"attachmentUrl" : `/v1/${req.parentType}/${req.parentId}/tasks/${taskId}/worklogs/${worklogId}/attachments/1`,
|
|
182
182
|
"attachmentUrl2" : `/v1/${req.parentType}/${req.parentId}/tasks/${taskId}/worklogs/${worklogId}/attachments/2`,
|
|
@@ -210,7 +210,7 @@ module.exports = (function () {
|
|
|
210
210
|
worklogId
|
|
211
211
|
);
|
|
212
212
|
|
|
213
|
-
const result = await task.getTaskWorklog(req.user.config, taskId, worklogId);
|
|
213
|
+
const result = await task.getTaskWorklog(req.user.config, taskId, worklogId, req.globalScriptParams);
|
|
214
214
|
const urls = {
|
|
215
215
|
"attachmentUrl" : `/v1/${req.parentType}/${req.parentId}/tasks/${taskId}/worklogs/${worklogId}/attachments/1`,
|
|
216
216
|
"attachmentUrl2" : `/v1/${req.parentType}/${req.parentId}/tasks/${taskId}/worklogs/${worklogId}/attachments/2`,
|
package/routes/ticketRoutes.js
CHANGED
|
@@ -35,7 +35,7 @@ module.exports = (function() {
|
|
|
35
35
|
options.offset = Number.parseInt(offset);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
ticketController.getTickets(req.ticketConfig, req.user.config, includeString, options).then(function (result) {
|
|
38
|
+
ticketController.getTickets(req.ticketConfig, req.user.config, includeString, options, req.globalScriptParams).then(function (result) {
|
|
39
39
|
log.debug('result', result);
|
|
40
40
|
req.includeObjectsList = result.included;
|
|
41
41
|
req.result = {data:result.data};
|
|
@@ -63,7 +63,7 @@ module.exports = (function() {
|
|
|
63
63
|
next(errors.array());
|
|
64
64
|
} else {
|
|
65
65
|
const relations = req.body.data.relations;
|
|
66
|
-
ticketController.createTicket(req.ticketConfig, req.user.config, req.body.data).then(async function (createResult) {
|
|
66
|
+
ticketController.createTicket(req.ticketConfig, req.user.config, req.body.data, req.globalScriptParams).then(async function (createResult) {
|
|
67
67
|
const ticketId = createResult.data[0][req.ticketConfig.ticketIdField];
|
|
68
68
|
eventLog.setTicketId(req, ticketId);
|
|
69
69
|
req.eventData.ticketNumber = ticketId;
|
|
@@ -109,7 +109,7 @@ module.exports = (function() {
|
|
|
109
109
|
if (!valResult.isEmpty()) {
|
|
110
110
|
next(valResult.array());
|
|
111
111
|
} else {
|
|
112
|
-
ticketController.searchTicket(req.ticketConfig, req.user.config, req.body.searchString, req.body.fields, options, includeString).then(function (result) {
|
|
112
|
+
ticketController.searchTicket(req.ticketConfig, req.user.config, req.body.searchString, req.body.fields, options, includeString, req.globalScriptParams).then(function (result) {
|
|
113
113
|
log.debug('result', result);
|
|
114
114
|
req.includeObjectsList = result.included;
|
|
115
115
|
req.result = {data:result.data};
|
|
@@ -136,7 +136,7 @@ module.exports = (function() {
|
|
|
136
136
|
});
|
|
137
137
|
|
|
138
138
|
function getTicket(req, res, next, clientConfig, id, mapping, includeString) {
|
|
139
|
-
ticketController.getTicket(req.ticketConfig, clientConfig, id, mapping, includeString).then(function (result) {
|
|
139
|
+
ticketController.getTicket(req.ticketConfig, clientConfig, id, mapping, includeString, req.globalScriptParams).then(function (result) {
|
|
140
140
|
log.debug('result', result);
|
|
141
141
|
req.includeObjectsList = result.included;
|
|
142
142
|
req.result = {data:result.data || {}};
|
|
@@ -167,7 +167,7 @@ module.exports = (function() {
|
|
|
167
167
|
next(errors.array());
|
|
168
168
|
} else {
|
|
169
169
|
const relations = req.body.data.relations;
|
|
170
|
-
ticketController.updateTicket(req.ticketConfig, req.user.config, id, req.body.data)
|
|
170
|
+
ticketController.updateTicket(req.ticketConfig, req.user.config, id, req.body.data, req.globalScriptParams)
|
|
171
171
|
.then(async function (updateResult) {
|
|
172
172
|
await ticketCIRelationController.updateRelations(req.ticketConfig, req.user.config, id, relations);
|
|
173
173
|
getTicket(req, res, next, req.user.config, id, null, includeString);
|
|
@@ -23,7 +23,7 @@ module.exports = (function() {
|
|
|
23
23
|
id
|
|
24
24
|
);
|
|
25
25
|
|
|
26
|
-
ticketWorkLogController.getWorklogs(req.ticketConfig, req.user.config, id).then(function (result) {
|
|
26
|
+
ticketWorkLogController.getWorklogs(req.ticketConfig, req.user.config, id, undefined, req.globalScriptParams).then(function (result) {
|
|
27
27
|
req.result = {
|
|
28
28
|
data: result.data
|
|
29
29
|
};
|
|
@@ -45,7 +45,7 @@ module.exports = (function() {
|
|
|
45
45
|
null,
|
|
46
46
|
worklogId
|
|
47
47
|
);
|
|
48
|
-
ticketWorkLogController.getWorklog(req.ticketConfig, req.user.config, ticketId, worklogId).then(function (result) {
|
|
48
|
+
ticketWorkLogController.getWorklog(req.ticketConfig, req.user.config, ticketId, worklogId, undefined, req.globalScriptParams).then(function (result) {
|
|
49
49
|
req.result = result;
|
|
50
50
|
next();
|
|
51
51
|
}).catch(function (reason) {
|
|
@@ -163,12 +163,12 @@ module.exports = (function() {
|
|
|
163
163
|
isPublic = true;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
ticketWorkLogController.createWorklog(req.ticketConfig, req.user.config, ticketId, req.body.data.summary, req.body.data.text, isPublic)
|
|
166
|
+
ticketWorkLogController.createWorklog(req.ticketConfig, req.user.config, ticketId, req.body.data.summary, req.body.data.text, isPublic, req.globalScriptParams)
|
|
167
167
|
.then(result => {
|
|
168
168
|
const worklogId = result['0'];
|
|
169
169
|
req.eventData.ticketNumber2 = worklogId;
|
|
170
170
|
log.debug('WorkLog created', worklogId);
|
|
171
|
-
ticketWorkLogController.getWorklog(req.ticketConfig, req.user.config, ticketId, worklogId).then(worklogResult => {
|
|
171
|
+
ticketWorkLogController.getWorklog(req.ticketConfig, req.user.config, ticketId, worklogId, undefined, req.globalScriptParams).then(worklogResult => {
|
|
172
172
|
req.result = worklogResult;
|
|
173
173
|
next();
|
|
174
174
|
});
|