File tree Expand file tree Collapse file tree 2 files changed +48
-0
lines changed
Server-Side Components/Business Rules/Auto-Generate Knowledge Article for Resolved Incidents Expand file tree Collapse file tree 2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 1+ ## Overview
2+ This ServiceNow Business Rule automatically creates a Knowledge Article when an Incident is resolved and includes detailed resolution notes.
3+ It helps promote knowledge sharing, reduce repeated issues, and improve ITSM efficiency.
4+
5+
6+ ## Features
7+ - Automatically creates a Knowledge Article in the ** Draft** state.
8+ - Extracts content from the Incident's ** Resolution Notes** .
9+ - Prevents duplicate Knowledge Articles by checking for similar issue titles.
Original file line number Diff line number Diff line change 1+ ( function executeRule ( current , previous ) {
2+
3+ // Only run when the incident moves to Resolved
4+ if ( current . state == previous . state || current . state != 6 ) {
5+ return ;
6+ }
7+
8+ // Make sure we have resolution notes to use for the KB article
9+ if ( ! current . close_notes ) {
10+ gs . info ( 'Skipping KB creation: No resolution notes found for ' + current . number ) ;
11+ return ;
12+ }
13+
14+ // Get a clean version of the short description for comparison
15+ var issueTitle = current . short_description ? current . short_description . toLowerCase ( ) . trim ( ) : '' ;
16+
17+ // Check if a similar KB article already exists
18+ var kbCheck = new GlideRecord ( 'kb_knowledge' ) ;
19+ kbCheck . addQuery ( 'short_description' , 'CONTAINS' , issueTitle ) ;
20+ kbCheck . query ( ) ;
21+
22+ if ( kbCheck . next ( ) ) {
23+ gs . info ( 'KB already exists for issue: ' + current . number + '. Skipping new KB creation.' ) ;
24+ return ;
25+ }
26+
27+ // Create a new Knowledge Article
28+ var kb = new GlideRecord ( 'kb_knowledge' ) ;
29+ kb . initialize ( ) ;
30+ kb . short_description = current . short_description ;
31+ kb . text = current . close_notes ;
32+ kb . workflow_state = 'draft' ;
33+ kb . kb_category = '' ; // You can set a default category if needed
34+ kb . u_source_incident = current . number ; // Optional: track which incident created it
35+ kb . insert ( ) ;
36+
37+ gs . info ( 'New KB article created from Incident: ' + current . number ) ;
38+
39+ } ) ( current , previous ) ;
You can’t perform that action at this time.
0 commit comments