Skip to content

Commit 854a1e2

Browse files
authored
Business rule (ServiceNowDevProgram#712)
* Create Replace Script.js This Script help to update the author of knowledge article, if author leaves the organization. * Create Readme.md This business rule help to replace the KB author of knowledge article to Knowledge base manager, if the author of that article leaves the organization. This is a kind of logic which helps to assign the knowledge article to knowledge base manager.
1 parent b356981 commit 854a1e2

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
This business rule help to replace the KB author of knowledge article to Knowledge base manager, if the author of that article leaves the organization. This is a kind of logic which helps to assign the knowledge article to knowledge base manager.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
(function executeRule(current, previous /*null when async*/ ) {
2+
var test_kb_manager;
3+
var test_arr_kb_manager;
4+
if (active == false) { // This will check if user is inactive.
5+
var kb_gr = new GlideRecord("kb_knowledge");
6+
kb_gr.addEncodedQuery("author=" + current.sys_id); // This will query the knowledge article.
7+
kb_gr.query();
8+
while (kb_gr.next()) {
9+
if (test_kb_manager != "") {
10+
test_kb_manager = kb_gr.kb_knowledge_base.kb_manager;
11+
test_arr_kb_manage = test_kb_manager.split(","); // This will seperate the list of manager by (,).
12+
kb_gr.author = test_arr_kb_manager[0]; // This will assign the article author to knowledge manager.
13+
kb_gr.update();
14+
15+
}
16+
}
17+
}
18+
19+
})(current, previous);

0 commit comments

Comments
 (0)