Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## Overview
This ServiceNow Business Rule automatically creates a Knowledge Article when an Incident is resolved and includes detailed resolution notes.
It helps promote knowledge sharing, reduce repeated issues, and improve ITSM efficiency.


## Features
- Automatically creates a Knowledge Article in the **Draft** state.
- Extracts content from the Incident's **Resolution Notes**.
- Prevents duplicate Knowledge Articles by checking for similar issue titles.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
(function executeRule(current, previous) {

// Only run when the incident moves to Resolved
if (current.state == previous.state || current.state != 6) {
return;
}

// Make sure we have resolution notes to use for the KB article
if (!current.close_notes) {
gs.info('Skipping KB creation: No resolution notes found for ' + current.number);
return;
}

// Get a clean version of the short description for comparison
var issueTitle = current.short_description ? current.short_description.toLowerCase().trim() : '';

// Check if a similar KB article already exists
var kbCheck = new GlideRecord('kb_knowledge');
kbCheck.addQuery('short_description', 'CONTAINS', issueTitle);
kbCheck.query();

if (kbCheck.next()) {
gs.info('KB already exists for issue: ' + current.number + '. Skipping new KB creation.');
return;
}

// Create a new Knowledge Article
var kb = new GlideRecord('kb_knowledge');
kb.initialize();
kb.short_description = current.short_description;
kb.text = current.close_notes;
kb.workflow_state = 'draft';
kb.kb_category = ''; // You can set a default category if needed
kb.u_source_incident = current.number; // Optional: track which incident created it
kb.insert();

gs.info('New KB article created from Incident: ' + current.number);

})(current, previous);
Loading