Skip to content

Commit af2f354

Browse files
authored
Create script.js
Add Business Rule: Auto-Generate Knowledge Article from Resolved Incident
1 parent f8120aa commit af2f354

File tree

1 file changed

+17
-0
lines changed
  • Server-Side Components/Business Rules/Auto-Generate-KB-Article

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
(function executeRule(current, previous /*null when async*/) {
2+
try {
3+
// Check if Incident is resolved and has a resolution note
4+
if (current.state == 6 && current.close_notes) { // 6 = Resolved
5+
var kbGR = new GlideRecord("kb_knowledge");
6+
kbGR.initialize();
7+
kbGR.short_description = "Resolution for Incident " + current.number;
8+
kbGR.text = current.close_notes;
9+
kbGR.kb_category = "General"; // Default category, can be customized
10+
kbGR.workflow_state = "draft";
11+
kbGR.u_source_incident = current.sys_id; // Optional: custom field to track source
12+
kbGR.insert();
13+
}
14+
} catch (ex) {
15+
gs.error("An error occurred while creating a Knowledge Article from Incident.");
16+
}
17+
})(current, previous);

0 commit comments

Comments
 (0)