Skip to content

Commit 4d1eee5

Browse files
Creation of new Background script : Bulk Update of Fulfillment Group References in Published KB Articles (#1804)
* Create Code.js * Create README.md * Add Business rule: Add or remove tag to the ticket * Rename code.js to code.js * Rename README.md to README.md * Adding new UI Action: Generate PDF * Adding new UI Action: Generate PDF * Adding new Background script: Bulk Update of Fulfillment Group References in Published KB Articles * Adding new Background script: Bulk Update of Fulfillment Group References in Published KB Articles * Delete Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles directory * Adding new BG script: Bulk Update of Fulfillment Group References in Published KB Articles * Create README.md * Delete Client-Side Components/UI Actions/Generate PDF/README.md * Delete Client-Side Components/UI Actions/Generate PDF/Script.js
1 parent 0391aa1 commit 4d1eee5

File tree

2 files changed

+16
-0
lines changed
  • Server-Side Components/Background Scripts/Bulk Update of Fulfillment Group References in Published KB Articles

2 files changed

+16
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Description:
2+
This background script is used to automatically update the content of all published Knowledge Base articles by replacing outdated group references, ensuring consistency and relevance across documentation without the need to manually check out and edit each article
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
var old_reference = "Service desk"; // Old group name
2+
var new_reference = "Help desk"; // New group name
3+
4+
var regexPattern = new RegExp('(?is)'+ old_reference, 'gi'); // Building Regex to generate case-insensitive pattern
5+
6+
var kb_article = new GlideRecord('kb_knowledge');
7+
kb_article.addEncodedQuery('workflow_state=published');
8+
kb_article.query();
9+
while(kb_article.next()){
10+
kb_article.text = kb_article.text.replace(regexPattern,new_reference); // Replacing the old group reference with the new group
11+
kb_article.setWorkflow(false);
12+
kb_article.update();
13+
gs.info('Updated Article: ' + kb_article.number);
14+
}

0 commit comments

Comments
 (0)