Skip to content

Commit 661a958

Browse files
authored
Script to create JSON Payload creation for custom REST integration
1 parent 7cf9aaf commit 661a958

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
//Script to create JSON Payload for Custom REST Integration
2+
//
3+
4+
incident: function(inci,comment,work_note) {
5+
var getInc = new GlideRecord('incident');
6+
getInc.get(inci);
7+
var com='',wn='';
8+
if(comment=='true')
9+
{
10+
com = getInc.comments.getJournalEntry(1);
11+
}
12+
if(work_note=='true')
13+
{
14+
wn = getInc.work_notes.getJournalEntry(1);
15+
}
16+
17+
var inc = {
18+
"short_description": getInc.getValue('short_description'),
19+
"sysid": getInc.getValue('sys_id'),
20+
"state": getInc.getValue('state'),
21+
"impact": getInc.getValue('impact'),
22+
"urgency": getInc.getValue('urgency'),
23+
"service": getInc.getValue('service'),
24+
"category": getInc.getValue('category'),
25+
"sub_category": getInc.getValue('sub_category'),
26+
"comments": com,
27+
"work_notes": wn,
28+
"configuration_item": getInc.getValue('cmdb_ci'),
29+
// We can add more required fields
30+
};
31+
var result = JSON.stringify(inc);
32+
return result; // We can also return the JSON also just by "return inc;"
33+
},

0 commit comments

Comments
 (0)