Skip to content

Commit 835f9de

Browse files
Merge branch 'ServiceNowDevProgram:main' into main
2 parents eec21a3 + 4d1eee5 commit 835f9de

File tree

4 files changed

+47
-0
lines changed
  • Server-Side Components

4 files changed

+47
-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+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(function executeRule(current, previous /*null when async*/ ) {
2+
/*
3+
Fire this BR when a tag is removed/deleted from a record.
4+
Retrieve the tag name, the user who removed the tag, and the tag removal date.
5+
Update the above information onto the tag-referenced record in this example, In this example its incident record
6+
*/
7+
var updateRecord = new GlideRecord(current.table);
8+
if (updateRecord.get(current.table_key)) {
9+
var notes = "Tag Name:" + " " + current.label.getDisplayValue() + "\n" + "Tag Removed By:" + " " + current.sys_updated_by + "\n" + "Tag Removed On:" + " " + current.sys_updated_on;
10+
//updateRecord.setValue("work_notes", notes);
11+
updateRecord.work_notes = notes;
12+
updateRecord.update();
13+
}
14+
})(current, previous);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
**Configure the following business rule on the label_entry table:**
2+
3+
1.Ensure the "Delete" operation is selected and the rule runs onBefore.
4+
5+
2.Retrieve the table name where the tag is removed.
6+
7+
3.Update the worknotes to track who removed the tag and when it was removed.
8+
<img width="952" height="460" alt="image" src="https://github.com/user-attachments/assets/020525dc-c98d-4ae8-94f9-d77cca6680e7" />
9+
<img width="1665" height="739" alt="image" src="https://github.com/user-attachments/assets/46c930eb-c031-4e1e-b1e6-31a3c64debb0" />
10+
11+
12+
**Output:**
13+
14+
<img width="1139" height="818" alt="image" src="https://github.com/user-attachments/assets/ed07f380-f279-4eca-82a5-208ae54054e7" />
15+
16+
<img width="780" height="401" alt="image" src="https://github.com/user-attachments/assets/283b40e1-1d7c-42aa-85f8-b8e9c6ccc3d0" />
17+

0 commit comments

Comments
 (0)