Skip to content

Commit 2650d8b

Browse files
authored
Create Creation of Problem
This ServiceNow Script Include automates the creation of a Problem record from an existing Incident record.
1 parent f9a60bc commit 2650d8b

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
var CreateProblemFromIncident = Class.create();
2+
CreateProblemFromIncident.prototype = {
3+
initialize: function() {
4+
},
5+
6+
createProblem: function(incidentSysId) {
7+
var incidentGR = new GlideRecord('incident');
8+
if (!incidentGR.get(incidentSysId)) {
9+
gs.error('Incident not found: ' + incidentSysId);
10+
return null;
11+
}
12+
13+
var problemGR = new GlideRecord('problem');
14+
problemGR.initialize();
15+
problemGR.short_description = 'Problem related to: ' + incidentGR.short_description;
16+
problemGR.description = 'Derived from Incident ' + incidentGR.number + ': ' + incidentGR.description;
17+
problemGR.impact = incidentGR.impact;
18+
problemGR.urgency = incidentGR.urgency;
19+
problemGR.priority = incidentGR.priority;
20+
problemGR.cmdb_ci = incidentGR.cmdb_ci;
21+
problemGR.opened_by = gs.getUserID();
22+
problemGR.insert();
23+
24+
// Link the incident to the problem
25+
incidentGR.problem_id = problemGR.sys_id;
26+
incidentGR.update();
27+
28+
return problemGR.sys_id;
29+
},
30+
31+
type: 'CreateProblemFromIncident'
32+
};

0 commit comments

Comments
 (0)