From 8307f0889a624444ce81f4c76d01b754c7135087 Mon Sep 17 00:00:00 2001 From: Chaitanya Reddy <93564567+LakshmiChaitanyaReddy@users.noreply.github.com> Date: Mon, 13 Oct 2025 13:06:20 +0530 Subject: [PATCH 1/2] Create README.md --- .../README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Find All Categories Related to a Knowledge Base/README.md diff --git a/Server-Side Components/Background Scripts/Find All Categories Related to a Knowledge Base/README.md b/Server-Side Components/Background Scripts/Find All Categories Related to a Knowledge Base/README.md new file mode 100644 index 0000000000..c3d1ac918b --- /dev/null +++ b/Server-Side Components/Background Scripts/Find All Categories Related to a Knowledge Base/README.md @@ -0,0 +1,5 @@ +Use case: there is no field on the Knowledge category table which points back to the Knowledge base it belongs to. + +To find the all the related categories of a knowledge base use this script. + +This script Recursively go through categories and pull the related categories. From 84035f63f37f0b32f4f1494687ebcb1dc0a7a3df Mon Sep 17 00:00:00 2001 From: Chaitanya Reddy <93564567+LakshmiChaitanyaReddy@users.noreply.github.com> Date: Mon, 13 Oct 2025 13:07:37 +0530 Subject: [PATCH 2/2] Create GetAllTheCategoriesRelatedToAKnowledgeBase.js --- ...AllTheCategoriesRelatedToAKnowledgeBase.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Server-Side Components/Background Scripts/Find All Categories Related to a Knowledge Base/GetAllTheCategoriesRelatedToAKnowledgeBase.js diff --git a/Server-Side Components/Background Scripts/Find All Categories Related to a Knowledge Base/GetAllTheCategoriesRelatedToAKnowledgeBase.js b/Server-Side Components/Background Scripts/Find All Categories Related to a Knowledge Base/GetAllTheCategoriesRelatedToAKnowledgeBase.js new file mode 100644 index 0000000000..7e48a31fb4 --- /dev/null +++ b/Server-Side Components/Background Scripts/Find All Categories Related to a Knowledge Base/GetAllTheCategoriesRelatedToAKnowledgeBase.js @@ -0,0 +1,19 @@ +var categoriesList = []; + +function GetAllTheCategoriesRelatedToAKnowledgeBase(parentID, categoriesList) { + + if (!parentID) + return; + + var catGr = new GlideRecord('kb_category'); + catGr.addQuery('parent_id', parentID); + catGr.query(); + while (catGr.next()) { + categoriesList.push(catGr.getValue('sys_id')); + gs.info(catGr.getValue('label')); + GetAllTheCategoriesRelatedToAKnowledgeBase(catGr.getValue('sys_id'), categoriesList); + } + return categoriesList; + +} +gs.info(GetAllTheCategoriesRelatedToAKnowledgeBase('a7e8a78bff0221009b20ffffffffff17' /*replace with your Knowledge Base Sysid*/ , categoriesList));