@manyos/smileconnect-api 1.41.3 → 1.42.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 +6 -3
- package/conf/clients.json +8 -7
- package/conf/customFormMapping.json +30 -0
- package/conf/mapping.json +4 -34
- package/controller/customFormController.js +13 -13
- package/controller/taskController.js +11 -11
- package/controller/ticketController.js +1 -0
- package/controller/ticketWorkLogController.js +2 -0
- package/docs/openapi.json +27 -27
- package/docs/releases.md +9 -4
- package/package.json +1 -1
- package/routes/appConfigRoutes.js +102 -0
- package/routes/customFormRoutes.js +5 -5
- package/routes/taskRoutes.js +1 -1
- package/test/workorderTest.js +1 -1
- package/util/config.js +55 -2
- package/util/constants.js +1 -0
- package/util/mappingUtil.js +76 -1
- package/util/paramHelper.js +1 -0
- package/util/schemas/fieldMappingSchema.js +28 -1
- package/util/searchUtil.js +68 -1
- package/docs/old/getting-started.md +0 -19
- package/docs/old/index.md +0 -41
- package/docs/old/installation.md +0 -123
- package/docs/old/postinstall.md +0 -169
- package/docs/old/preinstall.md +0 -19
- package/docs/old/tags.html +0 -34
- package/docs/old/workflow.md +0 -127
package/app.js
CHANGED
|
@@ -296,10 +296,13 @@ app.use('/v1/templates/(|incidents|problems|workorders|changes|tasks)', function
|
|
|
296
296
|
}, templateRoutes);
|
|
297
297
|
|
|
298
298
|
//formhandling
|
|
299
|
-
app.use('/v1/customForms/:
|
|
299
|
+
app.use('/v1/customForms/:formAlias', async function(req, res, next) {
|
|
300
|
+
const formAlias = req.params.formAlias
|
|
301
|
+
const formMapping = await config.getCustomFormMapping(formAlias)
|
|
300
302
|
req.formConfig = {
|
|
301
|
-
formName:
|
|
302
|
-
configName: 'custom_' +
|
|
303
|
+
formName: formMapping.formName,
|
|
304
|
+
configName: 'custom_' + formMapping.formName,
|
|
305
|
+
mapping: formMapping.mapping
|
|
303
306
|
}
|
|
304
307
|
req.parentEventBase = 'customForm'
|
|
305
308
|
next();
|
package/conf/clients.json
CHANGED
|
@@ -137,7 +137,6 @@
|
|
|
137
137
|
"translateSelectionFieldsX": false
|
|
138
138
|
},
|
|
139
139
|
"custom_Sample:Enrollments": {
|
|
140
|
-
"formName": "Sample:Enrollments",
|
|
141
140
|
"basequery": "1=1",
|
|
142
141
|
"fields": [
|
|
143
142
|
"Enrollment ID",
|
|
@@ -369,7 +368,8 @@
|
|
|
369
368
|
"Direct Contact Person ID",
|
|
370
369
|
"Submit Date",
|
|
371
370
|
"Last Modified Date",
|
|
372
|
-
"Resolution"
|
|
371
|
+
"Resolution",
|
|
372
|
+
"Submitter"
|
|
373
373
|
],
|
|
374
374
|
"constants": [
|
|
375
375
|
{
|
|
@@ -395,6 +395,10 @@
|
|
|
395
395
|
{
|
|
396
396
|
"name": "Status",
|
|
397
397
|
"value": "0"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
"name": "Submitter",
|
|
401
|
+
"value": "Horstinaut"
|
|
398
402
|
}
|
|
399
403
|
],
|
|
400
404
|
"basequery": "1=1",
|
|
@@ -607,7 +611,8 @@
|
|
|
607
611
|
"taskWorklog": {
|
|
608
612
|
"fields": [
|
|
609
613
|
"Summary",
|
|
610
|
-
"Notes"
|
|
614
|
+
"Notes",
|
|
615
|
+
"View Access"
|
|
611
616
|
],
|
|
612
617
|
"constants": [
|
|
613
618
|
{
|
|
@@ -621,10 +626,6 @@
|
|
|
621
626
|
{
|
|
622
627
|
"name": "Communication Source",
|
|
623
628
|
"value": "Other"
|
|
624
|
-
},
|
|
625
|
-
{
|
|
626
|
-
"name": "View Access",
|
|
627
|
-
"value": "Internal"
|
|
628
629
|
}
|
|
629
630
|
],
|
|
630
631
|
"basequery": "",
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"persons": {
|
|
3
|
+
"formName": "CTM:People",
|
|
4
|
+
"mapping": {
|
|
5
|
+
"Remedy Login ID": "id",
|
|
6
|
+
"Full Name": "name"
|
|
7
|
+
}
|
|
8
|
+
},
|
|
9
|
+
"enrollments": {
|
|
10
|
+
"formName": "Sample:Enrollments",
|
|
11
|
+
"mapping": {
|
|
12
|
+
"Enrollment ID": "id",
|
|
13
|
+
"Enrollee Login": "userId",
|
|
14
|
+
"Class ID": "classId",
|
|
15
|
+
"Class Title": "classTitle",
|
|
16
|
+
"Class Location": "location",
|
|
17
|
+
"Class Start Date & Time": "startDate",
|
|
18
|
+
"Class Cost": "cost",
|
|
19
|
+
"Department": "department"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"baseElement": {
|
|
23
|
+
"formName": "AST:BaseElement",
|
|
24
|
+
"mapping": {
|
|
25
|
+
"Instance Id": "id",
|
|
26
|
+
"Class Id": "class",
|
|
27
|
+
"Class Id2": "class4"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
package/conf/mapping.json
CHANGED
|
@@ -1,38 +1,4 @@
|
|
|
1
1
|
{
|
|
2
|
-
"custom_Sample:Enrollments": [
|
|
3
|
-
{
|
|
4
|
-
"oldName": "Enrollment ID",
|
|
5
|
-
"newName": "id"
|
|
6
|
-
},
|
|
7
|
-
{
|
|
8
|
-
"oldName": "Enrollee Login",
|
|
9
|
-
"newName": "userId"
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
"oldName": "Class ID",
|
|
13
|
-
"newName": "classId"
|
|
14
|
-
},
|
|
15
|
-
{
|
|
16
|
-
"oldName": "Class Title",
|
|
17
|
-
"newName": "classTitle"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
"oldName": "Class Location",
|
|
21
|
-
"newName": "location"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"oldName": "Class Start Date & Time",
|
|
25
|
-
"newName": "startDate"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
"oldName": "Class Cost",
|
|
29
|
-
"newName": "cost"
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
"oldName": "Department",
|
|
33
|
-
"newName": "department"
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
2
|
"cmdbobject": [
|
|
37
3
|
{
|
|
38
4
|
"oldName": "Instance Id",
|
|
@@ -949,6 +915,10 @@
|
|
|
949
915
|
{
|
|
950
916
|
"oldName": "TaskOrTaskGroupInstanceId",
|
|
951
917
|
"newName": "TaskOrTaskGroupInstanceId"
|
|
918
|
+
},
|
|
919
|
+
{
|
|
920
|
+
"oldName": "View Access",
|
|
921
|
+
"newName": "viewAccess"
|
|
952
922
|
}
|
|
953
923
|
],
|
|
954
924
|
"flowBuilder": [
|
|
@@ -6,7 +6,7 @@ const CacheService = require ('../util/cache.service');
|
|
|
6
6
|
const config = require('../util/config');
|
|
7
7
|
const CONSTANTS = require('../util/constants');
|
|
8
8
|
const searchUtil = require('../util/searchUtil');
|
|
9
|
-
const {getIncludeArray,
|
|
9
|
+
const {getIncludeArray, applyCustomFormMapping} = require('../util/paramHelper');
|
|
10
10
|
const scriptController = require('./scriptController');
|
|
11
11
|
const mappingUtil = require('../util/mappingUtil');
|
|
12
12
|
|
|
@@ -31,12 +31,12 @@ async function createRecord(formConfig, clientConfig, data, globalScriptParams)
|
|
|
31
31
|
|
|
32
32
|
const requestType = formConfig.requestType;
|
|
33
33
|
|
|
34
|
-
const mapping =
|
|
34
|
+
const mapping = formConfig.mapping;
|
|
35
35
|
log.debug('mapping', mapping);
|
|
36
36
|
|
|
37
|
-
const fields =
|
|
37
|
+
const fields = clientConfig[formConfig.configName].fields
|
|
38
38
|
|
|
39
|
-
data = mappingUtil.
|
|
39
|
+
data = mappingUtil.applyCustomFormMapping2Remedy(data, mapping, clientConfig[formConfig.configName].constants, fields);
|
|
40
40
|
|
|
41
41
|
//run postScripts
|
|
42
42
|
if (scripts && scripts.postMapping) {
|
|
@@ -55,7 +55,7 @@ async function createRecord(formConfig, clientConfig, data, globalScriptParams)
|
|
|
55
55
|
log.error('Cannot create Record', resultInterfaceCreate);
|
|
56
56
|
throw({message: 'Cannot create Record', details : resultInterfaceCreate});
|
|
57
57
|
}
|
|
58
|
-
|
|
58
|
+
globalScriptParams.id = recordCreateId
|
|
59
59
|
//run afterExecution
|
|
60
60
|
if (scripts && scripts.afterExecution) {
|
|
61
61
|
await scriptController.runScripts(scripts.afterExecution, data, clientConfig.clientId, globalScriptParams);
|
|
@@ -84,7 +84,7 @@ function queryRecords(formConfig, clientConfig, query, mapping, customFields, cu
|
|
|
84
84
|
const key = baseQuery + fields.toString() + query + JSON.stringify(options) + includeArray;
|
|
85
85
|
log.debug('Cachekey is ', key);
|
|
86
86
|
if (mapping == null || mapping == undefined) {
|
|
87
|
-
mapping =
|
|
87
|
+
mapping = formConfig.mapping
|
|
88
88
|
}
|
|
89
89
|
log.debug('mapping', mapping);
|
|
90
90
|
|
|
@@ -124,7 +124,7 @@ async function handleRecord(formConfig, record, mapping, clientConfig, includeAr
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
|
|
127
|
+
mappingUtil.applyCustomFormMapping(record, mapping);
|
|
128
128
|
|
|
129
129
|
//run postScripts
|
|
130
130
|
if (scripts && scripts.postMapping) {
|
|
@@ -160,9 +160,9 @@ async function updateRecord(formConfig, clientConfig, id, recordData, globalScri
|
|
|
160
160
|
await scriptController.runScripts(scripts.preMapping, recordData, clientConfig.clientId, globalScriptParams);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
const mapping =
|
|
163
|
+
const mapping = formConfig.mapping
|
|
164
164
|
|
|
165
|
-
recordData = mappingUtil.
|
|
165
|
+
recordData = mappingUtil.applyCustomFormMapping2Remedy(recordData, mapping, clientConfig[formConfig.configName].constants, fields);
|
|
166
166
|
|
|
167
167
|
//run postMapping
|
|
168
168
|
if (scripts && scripts.postMapping) {
|
|
@@ -180,10 +180,10 @@ async function updateRecord(formConfig, clientConfig, id, recordData, globalScri
|
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
function searchRecords(formConfig, clientConfig, searchString, fields, options, includeString, globalScriptParams) {
|
|
183
|
-
const mapping =
|
|
184
|
-
const mappedString = searchUtil.
|
|
185
|
-
const customFields = searchUtil.
|
|
186
|
-
options.sort = searchUtil.
|
|
183
|
+
const mapping = formConfig.mapping
|
|
184
|
+
const mappedString = searchUtil.applyCustomFormMapping(searchString, mapping);
|
|
185
|
+
const customFields = searchUtil.getCustomFormFields(clientConfig[formConfig.configName].fields, mapping, fields);
|
|
186
|
+
options.sort = searchUtil.applyCustomFormSortMapping(options.sort, mapping);
|
|
187
187
|
return queryRecords(formConfig, clientConfig, mappedString, null, customFields, options, includeString, globalScriptParams);
|
|
188
188
|
}
|
|
189
189
|
|
|
@@ -81,6 +81,8 @@ async function createTask(clientConfig, rootForm, rootRequestId, taskData, creat
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
const taskResult = await arquery.createEntry('TMS:Task', taskData, clientConfig.options)
|
|
84
|
+
const taskId = taskResult['0'];
|
|
85
|
+
globalScriptParams.id2 = taskId;
|
|
84
86
|
|
|
85
87
|
//run afterExecution
|
|
86
88
|
if (scripts && scripts.afterExecution) {
|
|
@@ -113,7 +115,7 @@ async function createTask(clientConfig, rootForm, rootRequestId, taskData, creat
|
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
//Todo make dynamic
|
|
116
|
-
async function createWorklog(clientConfig, taskId,
|
|
118
|
+
async function createWorklog(clientConfig, taskId, data, globalScriptParams) {
|
|
117
119
|
const task = await getTask(clientConfig,taskId)
|
|
118
120
|
const fields = clientConfig.taskWorklog.fields;
|
|
119
121
|
|
|
@@ -124,19 +126,12 @@ async function createWorklog(clientConfig, taskId, summary, text, attachment, gl
|
|
|
124
126
|
const mapping = config.getMapping('taskWorklog');
|
|
125
127
|
|
|
126
128
|
log.debug('mapping', mapping);
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
"summary" : summary,
|
|
130
|
-
"text" : text,
|
|
131
|
-
"TaskOrTaskGroupID" : taskId,
|
|
132
|
-
"TaskOrTaskGroupInstanceId" : taskInstanceId
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
fields.push(
|
|
129
|
+
|
|
130
|
+
/*fields.push(
|
|
136
131
|
'Secure Log',
|
|
137
132
|
'TaskOrTaskGroupID',
|
|
138
133
|
'TaskOrTaskGroupInstanceId'
|
|
139
|
-
)
|
|
134
|
+
);*/
|
|
140
135
|
|
|
141
136
|
//run preScripts
|
|
142
137
|
if (scripts && scripts.preMapping) {
|
|
@@ -145,12 +140,17 @@ async function createWorklog(clientConfig, taskId, summary, text, attachment, gl
|
|
|
145
140
|
|
|
146
141
|
data = mappingUtil.applyMapping2Remedy(data, mapping, clientConfig.taskWorklog.constants, fields);
|
|
147
142
|
|
|
143
|
+
//add task ID fields after Mapping
|
|
144
|
+
data["TaskOrTaskGroupID"] = taskId
|
|
145
|
+
data["TaskOrTaskGroupInstanceId"] = taskInstanceId
|
|
146
|
+
|
|
148
147
|
//run postScripts
|
|
149
148
|
if (scripts && scripts.postMapping) {
|
|
150
149
|
await scriptController.runScripts(scripts.postMapping, data, clientConfig.clientId, globalScriptParams);
|
|
151
150
|
}
|
|
152
151
|
|
|
153
152
|
const result = await arquery.createEntry('TMS:WorkInfo', data, clientConfig.options)
|
|
153
|
+
globalScriptParams.id3 = result['0']
|
|
154
154
|
|
|
155
155
|
//run afterExecution
|
|
156
156
|
if (scripts && scripts.afterExecution) {
|
|
@@ -50,6 +50,7 @@ async function createTicket(ticketConfig, clientConfig, data, globalScriptParams
|
|
|
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
|
+
globalScriptParams.id = ticketId
|
|
53
54
|
} else {
|
|
54
55
|
log.error('Cannot create Ticket', resultInterfaceCreate);
|
|
55
56
|
throw({message: 'Cannot create Ticket', details : resultInterfaceCreate});
|
|
@@ -73,6 +73,8 @@ async function createWorklog(ticketConfig, clientConfig, ticketId, data, globalS
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
const result = arquery.createEntry(ticketConfig.forms.workLog, data, clientConfig.options)
|
|
76
|
+
const worklogId = result['0'];
|
|
77
|
+
globalScriptParams.id2 = worklogId
|
|
76
78
|
|
|
77
79
|
//run afterExecution
|
|
78
80
|
if (scripts && scripts.afterExecution) {
|
package/docs/openapi.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"openapi": "3.0.2",
|
|
3
3
|
"info": {
|
|
4
4
|
"title": "SMILEconnect",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.41.4",
|
|
6
6
|
"contact": {
|
|
7
7
|
"name": "manyos technology GmbH",
|
|
8
8
|
"url": "https://manyos.it",
|
|
@@ -4838,32 +4838,6 @@
|
|
|
4838
4838
|
"id": "WLG000000000533"
|
|
4839
4839
|
}
|
|
4840
4840
|
},
|
|
4841
|
-
"WorklogNew": {
|
|
4842
|
-
"title": "Root Type for Worklog",
|
|
4843
|
-
"description": "",
|
|
4844
|
-
"required": [
|
|
4845
|
-
"summary",
|
|
4846
|
-
"text"
|
|
4847
|
-
],
|
|
4848
|
-
"type": "object",
|
|
4849
|
-
"properties": {
|
|
4850
|
-
"summary": {
|
|
4851
|
-
"type": "string"
|
|
4852
|
-
},
|
|
4853
|
-
"text": {
|
|
4854
|
-
"type": "string"
|
|
4855
|
-
},
|
|
4856
|
-
"isPublic": {
|
|
4857
|
-
"description": "Defines whether this worklog is public or only internal. Public worklogs are share with the requestor of the ticket. Internal worklogs are only visible within the support organization.\nDefaults to false (internal only).",
|
|
4858
|
-
"type": "boolean"
|
|
4859
|
-
}
|
|
4860
|
-
},
|
|
4861
|
-
"example": {
|
|
4862
|
-
"summary": "Status Change",
|
|
4863
|
-
"text": "Status Marked: Resolved by Allen",
|
|
4864
|
-
"isPublic": true
|
|
4865
|
-
}
|
|
4866
|
-
},
|
|
4867
4841
|
"WorklogResponseList": {
|
|
4868
4842
|
"description": "",
|
|
4869
4843
|
"required": [
|
|
@@ -16078,6 +16052,32 @@
|
|
|
16078
16052
|
"id": "ars101",
|
|
16079
16053
|
"code": "try {\n const result = await adapter.remedy.search(params.form, params.query, params.valueField + ',' + params.labelField);\n const data = result.data.map(item => {\n return {\n \"value\":item[params.valueField],\n \"label\":item[params.labelField],\n }\n });\n resolve(data);\n} catch (error) {\n reject(error);\n}"
|
|
16080
16054
|
}
|
|
16055
|
+
},
|
|
16056
|
+
"WorklogNew": {
|
|
16057
|
+
"title": "Root Type for Worklog",
|
|
16058
|
+
"description": "",
|
|
16059
|
+
"required": [
|
|
16060
|
+
"summary",
|
|
16061
|
+
"text"
|
|
16062
|
+
],
|
|
16063
|
+
"type": "object",
|
|
16064
|
+
"properties": {
|
|
16065
|
+
"summary": {
|
|
16066
|
+
"type": "string"
|
|
16067
|
+
},
|
|
16068
|
+
"text": {
|
|
16069
|
+
"type": "string"
|
|
16070
|
+
},
|
|
16071
|
+
"isPublic": {
|
|
16072
|
+
"description": "Deprecated - use mapping of view Access instead. Will be removed in future versions.\n\nDefines whether this worklog is public or only internal. Public worklogs are share with the requestor of the ticket. Internal worklogs are only visible within the support organization.\nDefaults to false (internal only).",
|
|
16073
|
+
"type": "boolean"
|
|
16074
|
+
}
|
|
16075
|
+
},
|
|
16076
|
+
"example": {
|
|
16077
|
+
"summary": "Status Change",
|
|
16078
|
+
"text": "Status Marked: Resolved by Allen",
|
|
16079
|
+
"isPublic": true
|
|
16080
|
+
}
|
|
16081
16081
|
}
|
|
16082
16082
|
},
|
|
16083
16083
|
"responses": {
|
package/docs/releases.md
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## API
|
|
4
4
|
|
|
5
|
-
### 1.
|
|
5
|
+
### 1.42.0 - 08.09.21
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Add IDs to POST Actions for After Execution Scripts
|
|
8
8
|
|
|
9
|
-
### 1.41.
|
|
9
|
+
### 1.41.4 - 10.08.21
|
|
10
10
|
|
|
11
|
+
Fix mapping for Ticket Worklogs
|
|
12
|
+
Fix mapping for Task Worklogs
|
|
11
13
|
Fix issue with sort in Remedy Adapter
|
|
12
14
|
|
|
13
15
|
### 1.41.0 - 03.08.21
|
|
@@ -36,10 +38,13 @@ The eventmanager will check all outbound webhooks for an event. If one fails, th
|
|
|
36
38
|
|
|
37
39
|
## GUI
|
|
38
40
|
|
|
41
|
+
### 1.4.18 - 11.08.21
|
|
42
|
+
hovering on fields in mappingtable, destroys values in "new" mapping, in some situations
|
|
43
|
+
|
|
39
44
|
### 1.4.17 - 09.08.21
|
|
40
45
|
|
|
41
46
|
Multiple events caused an error in the UI.
|
|
42
47
|
|
|
43
48
|
### 1.4.16 - 02.08.21
|
|
44
49
|
|
|
45
|
-
Add Auth + Scripts to Event config
|
|
50
|
+
Add Auth + Scripts to Event config
|
package/package.json
CHANGED
|
@@ -86,6 +86,108 @@ module.exports = (function() {
|
|
|
86
86
|
}
|
|
87
87
|
});
|
|
88
88
|
|
|
89
|
+
routes.get('/mappings/customForms', isAuthorizedAdmin,
|
|
90
|
+
async function (req, res, next) {
|
|
91
|
+
setEventData(
|
|
92
|
+
req,
|
|
93
|
+
CONSTANTS.EVENT_BASE_APC,
|
|
94
|
+
CONSTANTS.EVENT_ACTION_QUERY,
|
|
95
|
+
CONSTANTS.FORM_APC_MAPPING_CUSTOMFORM
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
try {
|
|
99
|
+
const fieldMapping = await config.getCustomFormMapping();
|
|
100
|
+
log.debug('get all field mappings', fieldMapping);
|
|
101
|
+
if (fieldMapping == null || fieldMapping == undefined) {
|
|
102
|
+
next('Could not load mappings');
|
|
103
|
+
} else {
|
|
104
|
+
req.result = {
|
|
105
|
+
"data": fieldMapping
|
|
106
|
+
};
|
|
107
|
+
next();
|
|
108
|
+
}
|
|
109
|
+
} catch (error) {
|
|
110
|
+
next(error);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
routes.get('/mappings/customForms/:id', isAuthorizedAdmin,
|
|
115
|
+
async function (req, res, next) {
|
|
116
|
+
const id = req.params.id
|
|
117
|
+
setEventData(
|
|
118
|
+
req,
|
|
119
|
+
CONSTANTS.EVENT_BASE_APC,
|
|
120
|
+
CONSTANTS.EVENT_ACTION_QUERY,
|
|
121
|
+
CONSTANTS.FORM_APC_MAPPING_CUSTOMFORM,
|
|
122
|
+
id
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
try {
|
|
126
|
+
const fieldMapping = await config.getCustomFormMapping(id);
|
|
127
|
+
log.debug('get all field mappings', fieldMapping);
|
|
128
|
+
if (fieldMapping == null || fieldMapping == undefined) {
|
|
129
|
+
next('Could not load mappings');
|
|
130
|
+
} else {
|
|
131
|
+
req.result = {
|
|
132
|
+
"data": fieldMapping
|
|
133
|
+
};
|
|
134
|
+
next();
|
|
135
|
+
}
|
|
136
|
+
} catch (error) {
|
|
137
|
+
next(error);
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
routes.put('/mappings/customForms/:id', isAuthorizedAdmin,
|
|
142
|
+
checkSchema(fieldMappingSchemas.customFormMappingItemSchema),
|
|
143
|
+
async function (req, res, next) {
|
|
144
|
+
const id = req.params.id;
|
|
145
|
+
setEventData(
|
|
146
|
+
req,
|
|
147
|
+
CONSTANTS.EVENT_BASE_APC,
|
|
148
|
+
CONSTANTS.EVENT_ACTION_MODIFY,
|
|
149
|
+
CONSTANTS.FORM_APC_MAPPING_CUSTOMFORM,
|
|
150
|
+
id,
|
|
151
|
+
req.body
|
|
152
|
+
);
|
|
153
|
+
const errors = validationResult(req);
|
|
154
|
+
if (!errors.isEmpty()) {
|
|
155
|
+
req.errorStatus = 422;
|
|
156
|
+
next(errors.array());
|
|
157
|
+
} else {
|
|
158
|
+
try {
|
|
159
|
+
const data = await config.setCustomFormMapping(req.body.data, id)
|
|
160
|
+
req.result = {
|
|
161
|
+
data
|
|
162
|
+
}
|
|
163
|
+
next();
|
|
164
|
+
} catch (error) {
|
|
165
|
+
next(error);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
routes.put('/mappings/customForms', isAuthorizedAdmin,
|
|
171
|
+
async function (req, res, next) {
|
|
172
|
+
setEventData(
|
|
173
|
+
req,
|
|
174
|
+
CONSTANTS.EVENT_BASE_APC,
|
|
175
|
+
CONSTANTS.EVENT_ACTION_MODIFY,
|
|
176
|
+
CONSTANTS.FORM_APC_MAPPING_CUSTOMFORM,
|
|
177
|
+
undefined,
|
|
178
|
+
req.body
|
|
179
|
+
);
|
|
180
|
+
try {
|
|
181
|
+
const data = await config.setCustomFormMapping(req.body.data)
|
|
182
|
+
req.result = {
|
|
183
|
+
data
|
|
184
|
+
}
|
|
185
|
+
next();
|
|
186
|
+
} catch (error) {
|
|
187
|
+
next(error);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
|
|
89
191
|
routes.put('/mappings/fields/:id', isAuthorizedAdmin,
|
|
90
192
|
checkSchema(fieldMappingSchemas.fieldMappingItemSchema),
|
|
91
193
|
function (req, res, next) {
|
|
@@ -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, globalScriptParams).then(function (result) {
|
|
36
|
+
customFormController.getRecords(req.formConfig, req.user.config, includeString, options, req.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, globalScriptParams).then(async function (createResult) {
|
|
62
|
+
customFormController.createRecord(req.formConfig, req.user.config, req.body.data, req.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, globalScriptParams).then(function (result) {
|
|
107
|
+
customFormController.searchRecords(req.formConfig, req.user.config, req.body.searchString, req.body.fields, options, includeString, req.globalScriptParams).then(function (result) {
|
|
108
108
|
log.debug('result', result);
|
|
109
109
|
req.result = {data:result.data};
|
|
110
110
|
next();
|
|
@@ -131,7 +131,7 @@ module.exports = (function() {
|
|
|
131
131
|
|
|
132
132
|
function getRecord(req, res, next, clientConfig, id, mapping, includeString) {
|
|
133
133
|
req.globalScriptParams.id = id
|
|
134
|
-
customFormController.getRecord(req.formConfig, clientConfig, id, mapping, includeString, globalScriptParams).then(function (result) {
|
|
134
|
+
customFormController.getRecord(req.formConfig, clientConfig, id, mapping, includeString, req.globalScriptParams).then(function (result) {
|
|
135
135
|
log.debug('result', result);
|
|
136
136
|
req.includeObjectsList = result.included;
|
|
137
137
|
req.result = {data:result.data || {}};
|
|
@@ -162,7 +162,7 @@ module.exports = (function() {
|
|
|
162
162
|
req.errorStatus = 422;
|
|
163
163
|
next(errors.array());
|
|
164
164
|
} else {
|
|
165
|
-
customFormController.updateRecord(req.formConfig, req.user.config, id, req.body.data, globalScriptParams)
|
|
165
|
+
customFormController.updateRecord(req.formConfig, req.user.config, id, req.body.data, req.globalScriptParams)
|
|
166
166
|
.then(async function (updateResult) {
|
|
167
167
|
getRecord(req, res, next, req.user.config, id, null, includeString);
|
|
168
168
|
}).catch(function (reason) {
|
package/routes/taskRoutes.js
CHANGED
|
@@ -181,7 +181,7 @@ module.exports = (function () {
|
|
|
181
181
|
req.errorStatus = 422;
|
|
182
182
|
next(errors.array());
|
|
183
183
|
} else {
|
|
184
|
-
task.createWorklog(req.user.config, taskId, req.body.data
|
|
184
|
+
task.createWorklog(req.user.config, taskId, req.body.data, req.globalScriptParams)
|
|
185
185
|
.then(createResult => {
|
|
186
186
|
const worklogId = createResult['0'];
|
|
187
187
|
task.getTaskWorklog(req.user.config, taskId, worklogId, req.globalScriptParams).then(result => {
|
package/test/workorderTest.js
CHANGED
|
@@ -494,7 +494,7 @@ describe('Integration Tests - Workorders', function () {
|
|
|
494
494
|
chai.request(server)
|
|
495
495
|
.post(`/v1/workorders/${workorder.id}/tasks/${task.id}/worklogs`)
|
|
496
496
|
.set('Authorization', 'Bearer ' + authUser.access_token)
|
|
497
|
-
.send({data: {summary: "Worklog Summary", text: "Worklog Text"}})
|
|
497
|
+
.send({data: {summary: "Worklog Summary", text: "Worklog Text", "viewAccess": "Public"}})
|
|
498
498
|
.end(function (err, res) {
|
|
499
499
|
res.should.have.status(200);
|
|
500
500
|
res.body.data.should.be.an('object');
|