@manyos/smileconnect-api 1.38.1 → 1.39.1

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.
@@ -0,0 +1,207 @@
1
+ ---
2
+ layout: page
3
+ title: Scripts
4
+ subtitle: How-to modify data
5
+ use-site-title: true
6
+ bigimg: /img/gb-isapi.jpg
7
+ ---
8
+
9
+ # Introduction
10
+
11
+ Scripts are used to modify requests, gather data or to drive external actions.
12
+
13
+ Scripts can call adapter to interact with other systems and they can be reused.
14
+
15
+ #### **`workOrder_lookupSericeNameByReconId`**
16
+ ```javascript
17
+ //lookup service ci name if reconId is given
18
+
19
+ if (requestData['ReconciliationIdentity']) {
20
+ const remedyResult = await adapter.remedy.search("BMC.CORE:BMC_BusinessService", `'ReconciliationIdentity' = "${requestData['ReconciliationIdentity']}" AND 'DatasetId' = "BMC.ASSET"`, "Name")
21
+
22
+ if (remedyResult && remedyResult.data && remedyResult.data[0]) {
23
+ const data = remedyResult.data[0];
24
+ requestData['CI Name'] = data['Name'];
25
+ }
26
+
27
+ }
28
+ resolve()
29
+ ```
30
+
31
+ The above script will lookup the service name for a given reconciliation id.
32
+
33
+ # Accessible Variables
34
+
35
+ Within scripts the following variables are available.
36
+
37
+ ## params
38
+
39
+ The parameter params can be defined in a script and used when another script is called. This is useful to reuse scripts.
40
+
41
+ e.g.
42
+ ```javascript
43
+ const returnValue = await script('ars101', {}, params);
44
+ ```
45
+
46
+ ## globalScriptParams
47
+
48
+ Global script params are set by the application and handed over to the script. They include the following parameter:
49
+
50
+ * query: This property is an object containing a property for each query string parameter in the route.
51
+ * id: the id of the ticket. Only set in GET & PUT actions
52
+ * id2: the id of child ticket. e.g. Tasks or Worklogs. Only set in GET & PUT actions
53
+ * id2: the id of child worklogs. e.g. Tasksworklog. Only set in GET & PUT actions
54
+ * classId: the classId of cmdbobjects. Only set in POST & PUT actions
55
+
56
+ ```json
57
+ {
58
+ "query": {
59
+ "includeObjects": "true",
60
+ "limit": "3",
61
+ "include": "supportGroupRelations,persons"
62
+ },
63
+ "id": "INC000000001507"
64
+ }
65
+ ```
66
+
67
+ ## requestData
68
+
69
+ This parameter holds the complete request data.
70
+
71
+ ## clientId
72
+
73
+ This id of the client who executes the script.
74
+
75
+ ## executedByScript
76
+
77
+ This parameter will be set to *true* if the script is executed by another script.
78
+
79
+ ## env
80
+
81
+ This parameter allows access to the environment variables.
82
+
83
+ ## log
84
+
85
+ Can be used to write data to the applications log stream.
86
+
87
+ The following log level can be used:
88
+
89
+ * trace
90
+ * debug
91
+ * info
92
+ * warn
93
+ * error
94
+ * fatal
95
+
96
+ e.g.
97
+
98
+ ```javascript
99
+ log.debug('log text', variable);
100
+ log.info('log text', variable);
101
+ log.error('error text', variable);
102
+ ```
103
+
104
+ ## script
105
+
106
+ Can be used to execute a script within a script.
107
+
108
+ script(scriptId, requestData, params, scope)
109
+
110
+ e.g.
111
+ ```javascript
112
+ const returnValue = await script('ars101', {}, params);
113
+ ```
114
+
115
+ For more information see subscripts.
116
+
117
+ ## fetch
118
+
119
+ Allows access to external webservices via the package *node-fetch*
120
+
121
+ See https://www.npmjs.com/package/node-fetch for details.
122
+
123
+ ## adapter
124
+
125
+ Allows to make adapter calls. [See details](../configuration/adapter.md)
126
+
127
+ # Returning values
128
+
129
+ Values can be returned with the fuction *resolve()*
130
+
131
+ e.g.
132
+
133
+ ```javascript
134
+ const values = [
135
+ "value1",
136
+ "value2",
137
+ "value3"
138
+ ]
139
+ resolve (values)
140
+ ```
141
+
142
+ # Error handling
143
+
144
+ Values can be returned with the fuction *reject()*
145
+
146
+ e.g.
147
+
148
+ ```javascript
149
+ if (!params.form) {
150
+ reject("The parameter form is required")
151
+ }
152
+ ```
153
+
154
+ # Async calls
155
+
156
+ Within scripts *await* can be used to make async calls.
157
+
158
+ ```javascript
159
+ const returnValue = await script('ars101', {}, params);
160
+ ```
161
+
162
+ # Samples
163
+
164
+ ## Simple Static Menu
165
+
166
+ This script creates the data for a simple static menu in a Selection (Drop Down) field.
167
+
168
+ ```javascript
169
+ const data = [
170
+ {
171
+ "value": "Menu Item 1",
172
+ "label": "internalVal1"
173
+ },
174
+ {
175
+ "value": "Menu Item 2",
176
+ "label": "internalVal2"
177
+ },
178
+ {
179
+ "value": "Menu Item 3",
180
+ "label": "internalVal3"
181
+ },
182
+ {
183
+ "value": "Menu Item 4",
184
+ "label": "internalVal4"
185
+ }
186
+ ];
187
+ resolve(data);
188
+
189
+ ```
190
+
191
+ ## Simple Query Menu
192
+
193
+ This script calls another script query data for a menu.
194
+
195
+ ```javascript
196
+ //prepare params
197
+ const params = {
198
+ "query": "'Remedy Login ID'=\"astern\"",
199
+ "form": "CTM:People",
200
+ "labelField": "Full Name",
201
+ "valueField": "Remedy Login ID"
202
+ };
203
+ //execute script
204
+ const personResult = await script('remedy/ars101', {}, params, "global");
205
+ //return parameter
206
+ resolve(personResult);
207
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@manyos/smileconnect-api",
3
- "version": "1.38.1",
3
+ "version": "1.39.1",
4
4
  "description": "A proxy and abstraction layer for BMCs IT Service Management Suite",
5
5
  "main": "app.js",
6
6
  "scripts": {
@@ -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 || []};
@@ -107,6 +107,7 @@ module.exports = (function () {
107
107
  cmdbObjectRoutes.get('/:id', passport.authenticate('jwt', {session: false}),
108
108
  function (req, res, next) {
109
109
  const id = req.params.id;
110
+ req.globalScriptParams.id = id
110
111
  const includeString = req.query.include;
111
112
  eventLog.setEventData(
112
113
  req,
@@ -115,7 +116,7 @@ module.exports = (function () {
115
116
  CONSTANTS.FORM_ASSET,
116
117
  id
117
118
  );
118
- cmdbobjects.getCmdbObject(req.user.config, id, includeString).then(function (result) {
119
+ cmdbobjects.getCmdbObject(req.user.config, id, includeString, undefined, req.globalScriptParams).then(function (result) {
119
120
  log.debug('result', result);
120
121
  req.includeObjectsList = result.included;
121
122
  req.result = {data:result.data || {}};
@@ -165,6 +166,8 @@ module.exports = (function () {
165
166
  const id = req.params.id;
166
167
  const classId = req.body.classId;
167
168
  const includeString = req.query.include;
169
+ req.globalScriptParams.id = id
170
+ req.globalScriptParams.classId = classId
168
171
  eventLog.setEventData(
169
172
  req,
170
173
  CONSTANTS.EVENT_BASE_AST,
@@ -183,8 +186,8 @@ module.exports = (function () {
183
186
  const ci = req.body.data;
184
187
  const hasAccess = await cmdbobjects.hasAccess(req.user.config, id);
185
188
  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);
189
+ const result = await cmdbobjects.updateCmdbObject(req.ticketConfig, req.user.config, id, req.body.data, classId, req.globalScriptParams);
190
+ const ci = await cmdbobjects.getCmdbObject(req.user.config, id, includeString, undefined, req.globalScriptParams);
188
191
  req.result = ci;
189
192
  next();
190
193
  } else {
@@ -200,6 +203,7 @@ module.exports = (function () {
200
203
  cmdbObjectRoutes.post('/', checkSchema(fieldMappingSchemas.CMDBCreateDataSchema), async function (req, res, next) {
201
204
  const classId = req.body.classId;
202
205
  const includeString = req.query.include;
206
+ req.globalScriptParams.classId = classId
203
207
  eventLog.setEventData(
204
208
  req,
205
209
  CONSTANTS.EVENT_BASE_AST,
@@ -214,8 +218,9 @@ module.exports = (function () {
214
218
  //const clientConfig = config.getClientConfig(clientId);
215
219
  const result = [];
216
220
  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);
221
+ const ciInstanceId = await cmdbobjects.createCmdbObject(req.ticketConfig, req.user.config, classId, req.body.data, req.globalScriptParams);
222
+ req.globalScriptParams.id = ciInstanceId
223
+ const ci = await cmdbobjects.getCmdbObject(req.user.config, ciInstanceId, includeString, undefined, req.globalScriptParams);
219
224
  req.result = ci;
220
225
  next();
221
226
  } 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,8 @@ 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
+ req.globalScriptParams.id = id
134
+ customFormController.getRecord(req.formConfig, clientConfig, id, mapping, includeString, globalScriptParams).then(function (result) {
134
135
  log.debug('result', result);
135
136
  req.includeObjectsList = result.included;
136
137
  req.result = {data:result.data || {}};
@@ -145,6 +146,7 @@ module.exports = (function() {
145
146
 
146
147
  routes.put('/:id', function (req, res, next) {
147
148
  const id = req.params.id;
149
+ req.globalScriptParams.id = id
148
150
  const origData = JSON.parse(JSON.stringify(req.body));
149
151
  const includeString = req.query.include;
150
152
  eventLog.setEventData(
@@ -160,7 +162,7 @@ module.exports = (function() {
160
162
  req.errorStatus = 422;
161
163
  next(errors.array());
162
164
  } else {
163
- customFormController.updateRecord(req.formConfig, req.user.config, id, req.body.data)
165
+ customFormController.updateRecord(req.formConfig, req.user.config, id, req.body.data, globalScriptParams)
164
166
  .then(async function (updateResult) {
165
167
  getRecord(req, res, next, req.user.config, id, null, includeString);
166
168
  }).catch(function (reason) {
@@ -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();
@@ -85,6 +85,8 @@ module.exports = (function () {
85
85
  taskRoutes.get('/:taskId', async function (req, res, next) {
86
86
  const parentId = req.parentId;
87
87
  const taskId = req.params.taskId;
88
+ req.globalScriptParams.id = parentId
89
+ req.globalScriptParams.id2 = taskId
88
90
  eventLog.setEventData(
89
91
  req,
90
92
  req.parentEventBase + '_' + CONSTANTS.EVENT_BASE_TAS,
@@ -95,7 +97,7 @@ module.exports = (function () {
95
97
  taskId
96
98
  );
97
99
 
98
- const result = await task.getTaskByRootRequest(req.user.config, parentId, taskId);
100
+ const result = await task.getTaskByRootRequest(req.user.config, parentId, taskId, req.globalScriptParams);
99
101
  req.includeObjectsList = result.included;
100
102
  req.result = {data:result.data || {}};
101
103
  next();
@@ -103,6 +105,8 @@ module.exports = (function () {
103
105
 
104
106
  taskRoutes.put('/:taskId', function (req, res, next) {
105
107
  const taskId = req.params.taskId;
108
+ req.globalScriptParams.id = req.parentId;
109
+ req.globalScriptParams.id2 = taskId
106
110
  const origData = JSON.parse(JSON.stringify(req.body));
107
111
  eventLog.setEventData(
108
112
  req,
@@ -118,8 +122,8 @@ module.exports = (function () {
118
122
  req.errorStatus = 422;
119
123
  next(errors.array());
120
124
  } 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) {
125
+ task.updateTask(req.user.config, taskId, req.body.data, req.globalScriptParams).then(function (updateResult) {
126
+ task.getTaskByRootRequest(req.user.config, req.parentId, taskId, req.globalScriptParams).then(function (result) {
123
127
  req.includeObjectsList = result.included;
124
128
  req.result = {data:result.data || {}};
125
129
  next();
@@ -134,6 +138,8 @@ module.exports = (function () {
134
138
 
135
139
  taskRoutes.get('/:taskId/worklogs', async function (req, res, next) {
136
140
  const taskId = req.params.taskId;
141
+ req.globalScriptParams.id = req.parentId;
142
+ req.globalScriptParams.id2 = taskId
137
143
  eventLog.setEventData(
138
144
  req,
139
145
  req.parentEventBase + '_' + CONSTANTS.EVENT_BASE_TAS,
@@ -144,7 +150,7 @@ module.exports = (function () {
144
150
  taskId
145
151
  );
146
152
 
147
- const result = await task.getTaskWorklogs(req.user.config, taskId);
153
+ const result = await task.getTaskWorklogs(req.user.config, taskId, req.globalScriptParams);
148
154
  req.includeObjectsList = result.included;
149
155
  req.result = {data:result.data || {}};
150
156
  next();
@@ -158,6 +164,8 @@ module.exports = (function () {
158
164
 
159
165
  const origData = JSON.parse(JSON.stringify(req.body));
160
166
  const taskId = req.params.taskId;
167
+ req.globalScriptParams.id = req.parentId;
168
+ req.globalScriptParams.id2 = taskId
161
169
  eventLog.setEventData(
162
170
  req,
163
171
  req.parentEventBase + '_' + CONSTANTS.EVENT_BASE_TAS,
@@ -173,10 +181,10 @@ module.exports = (function () {
173
181
  req.errorStatus = 422;
174
182
  next(errors.array());
175
183
  } else {
176
- task.createWorklog(req.user.config, taskId, req.body.data.summary, req.body.data.text)
184
+ task.createWorklog(req.user.config, taskId, req.body.data.summary, req.body.data.text, undefined, req.globalScriptParams)
177
185
  .then(createResult => {
178
186
  const worklogId = createResult['0'];
179
- task.getTaskWorklog(req.user.config, taskId, worklogId).then(result => {
187
+ task.getTaskWorklog(req.user.config, taskId, worklogId, req.globalScriptParams).then(result => {
180
188
  const urls = {
181
189
  "attachmentUrl" : `/v1/${req.parentType}/${req.parentId}/tasks/${taskId}/worklogs/${worklogId}/attachments/1`,
182
190
  "attachmentUrl2" : `/v1/${req.parentType}/${req.parentId}/tasks/${taskId}/worklogs/${worklogId}/attachments/2`,
@@ -199,6 +207,9 @@ module.exports = (function () {
199
207
  taskRoutes.get('/:taskId/worklogs/:worklogId', async function (req, res, next) {
200
208
  const taskId = req.params.taskId;
201
209
  const worklogId = req.params.worklogId;
210
+ req.globalScriptParams.id = req.parentId;
211
+ req.globalScriptParams.id2 = taskId
212
+ req.globalScriptParams.id3 = worklogId
202
213
  eventLog.setEventData(
203
214
  req,
204
215
  req.parentEventBase + '_' + CONSTANTS.EVENT_BASE_TAS,
@@ -210,7 +221,7 @@ module.exports = (function () {
210
221
  worklogId
211
222
  );
212
223
 
213
- const result = await task.getTaskWorklog(req.user.config, taskId, worklogId);
224
+ const result = await task.getTaskWorklog(req.user.config, taskId, worklogId, req.globalScriptParams);
214
225
  const urls = {
215
226
  "attachmentUrl" : `/v1/${req.parentType}/${req.parentId}/tasks/${taskId}/worklogs/${worklogId}/attachments/1`,
216
227
  "attachmentUrl2" : `/v1/${req.parentType}/${req.parentId}/tasks/${taskId}/worklogs/${worklogId}/attachments/2`,
@@ -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,8 @@ 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
+ req.globalScriptParams.id = id
140
+ ticketController.getTicket(req.ticketConfig, clientConfig, id, mapping, includeString, req.globalScriptParams).then(function (result) {
140
141
  log.debug('result', result);
141
142
  req.includeObjectsList = result.included;
142
143
  req.result = {data:result.data || {}};
@@ -151,6 +152,7 @@ module.exports = (function() {
151
152
 
152
153
  ticketRoutes.put('/:id', function (req, res, next) {
153
154
  const id = req.params.id;
155
+ req.globalScriptParams.id = id
154
156
  const origData = JSON.parse(JSON.stringify(req.body));
155
157
  const includeString = req.query.include;
156
158
  eventLog.setEventData(
@@ -167,7 +169,7 @@ module.exports = (function() {
167
169
  next(errors.array());
168
170
  } else {
169
171
  const relations = req.body.data.relations;
170
- ticketController.updateTicket(req.ticketConfig, req.user.config, id, req.body.data)
172
+ ticketController.updateTicket(req.ticketConfig, req.user.config, id, req.body.data, req.globalScriptParams)
171
173
  .then(async function (updateResult) {
172
174
  await ticketCIRelationController.updateRelations(req.ticketConfig, req.user.config, id, relations);
173
175
  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
  };
@@ -36,6 +36,8 @@ module.exports = (function() {
36
36
  ticketWorkLogRoutes.get('/:worklogId', function (req, res, next) {
37
37
  const ticketId = req.parentId;
38
38
  const worklogId = req.params.worklogId;
39
+ req.globalScriptParams.id = ticketId
40
+ req.globalScriptParams.id2 = worklogId
39
41
  eventLog.setEventData(
40
42
  req,
41
43
  req.parentEventBase,
@@ -45,7 +47,7 @@ module.exports = (function() {
45
47
  null,
46
48
  worklogId
47
49
  );
48
- ticketWorkLogController.getWorklog(req.ticketConfig, req.user.config, ticketId, worklogId).then(function (result) {
50
+ ticketWorkLogController.getWorklog(req.ticketConfig, req.user.config, ticketId, worklogId, undefined, req.globalScriptParams).then(function (result) {
49
51
  req.result = result;
50
52
  next();
51
53
  }).catch(function (reason) {
@@ -163,12 +165,14 @@ module.exports = (function() {
163
165
  isPublic = true;
164
166
  }
165
167
 
166
- ticketWorkLogController.createWorklog(req.ticketConfig, req.user.config, ticketId, req.body.data.summary, req.body.data.text, isPublic)
168
+ ticketWorkLogController.createWorklog(req.ticketConfig, req.user.config, ticketId, req.body.data.summary, req.body.data.text, isPublic, req.globalScriptParams)
167
169
  .then(result => {
168
170
  const worklogId = result['0'];
169
171
  req.eventData.ticketNumber2 = worklogId;
172
+ req.globalScriptParams.id = ticketId
173
+ req.globalScriptParams.id2 = worklogId
170
174
  log.debug('WorkLog created', worklogId);
171
- ticketWorkLogController.getWorklog(req.ticketConfig, req.user.config, ticketId, worklogId).then(worklogResult => {
175
+ ticketWorkLogController.getWorklog(req.ticketConfig, req.user.config, ticketId, worklogId, undefined, req.globalScriptParams).then(worklogResult => {
172
176
  req.result = worklogResult;
173
177
  next();
174
178
  });