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)); 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.