diff --git a/Business Rules/Replace KB Author with Manager/Readme.md b/Business Rules/Replace KB Author with Manager/Readme.md new file mode 100644 index 0000000000..959926a73c --- /dev/null +++ b/Business Rules/Replace KB Author with Manager/Readme.md @@ -0,0 +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. diff --git a/Business Rules/Replace KB Author with Manager/Replace Script.js b/Business Rules/Replace KB Author with Manager/Replace Script.js new file mode 100644 index 0000000000..a7d83b4340 --- /dev/null +++ b/Business Rules/Replace KB Author with Manager/Replace Script.js @@ -0,0 +1,19 @@ +(function executeRule(current, previous /*null when async*/ ) { + var test_kb_manager; + var test_arr_kb_manager; + if (active == false) { // This will check if user is inactive. + var kb_gr = new GlideRecord("kb_knowledge"); + kb_gr.addEncodedQuery("author=" + current.sys_id); // This will query the knowledge article. + kb_gr.query(); + while (kb_gr.next()) { + if (test_kb_manager != "") { + test_kb_manager = kb_gr.kb_knowledge_base.kb_manager; + test_arr_kb_manage = test_kb_manager.split(","); // This will seperate the list of manager by (,). + kb_gr.author = test_arr_kb_manager[0]; // This will assign the article author to knowledge manager. + kb_gr.update(); + + } + } + } + +})(current, previous);