- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-09-2017 04:40 AM
Hi All,
We are trying to replicate the native functionality of Knowledge articles, which will group the KB by categories.
You can find the similar functionality at <instance_name>.service-now.com/$knowledge.do
The same functionality has to be built in a widget and use that in the Service Portal, Kindly let me know if anybody achieved this.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2017 04:25 AM
Actually the code will support any number of sub levels - I have never tried it with more than 3 levels though
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-17-2017 06:10 AM
Hei Lars!
I've downloaded your share app. and trying to edit the widget to suit knowledgebase. I struggle with the parent part. for service catalog, parent is empty on top , while in knowledge category, the parent_id has the knowledgebase as parent_id (and we even have several knowledge bases to complicate it). How would the parent query be in the widget code: assuming i have to edit this part:
kb uses parent_id instead of parent
var cat = {};
cat.title = sc.label.getDisplayValue();
cat.open = isSubCat(sc.sys_id,data.category_id) || data.category_id == sc.sys_id;
cat.sys_id = sc.getUniqueValue();
//cat.isParent = isParent(sc);
if (sc.getValue('parent'))
cat.parent = sc.getValue('parent');
else
cat.parent = "top";
if (!data.categories[cat.parent])
data.categories[cat.parent] = [];
data.categories[cat.parent].push(cat);
}
function isSubCat(cat,subcat) { //Check if a category is a subcategory to another
if (!subcat)
return false;
var sc = new GlideRecord('kb_category');
//Get our subcategory
if (sc.get(subcat)) {
//See if the main category is one of our parents
if (JSUtil.notNil(sc.parent_id)) {
if (sc.parent == cat)
return true;
return isSubCat(cat,sc.parent);
}
return false;
}
}
function getSubCategories(category) {
//find subcategories
var arr = [];
var sub = new GlideRecord('kb_category');
sub.addQuery('parent', category.sys_id);
sub.addActiveQuery();
sub.orderBy('label');
sub.query();
while (sub.next()) {
if (!$sp.canReadRecord("kb_category", sub.getUniqueValue()))
continue;
var subcategory = {};
subcategory.sys_id = sub.getUniqueValue();
subcategory.title = sub.label.getDisplayValue();
subcategory.subcategories = [];
subcategory.subcategories = getSubCategories(sub); //Find further subcategories
subcategory.open = isSubCat(sub.sys_id,data.category_id);
arr.push(subcategory);
}
return arr;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-02-2017 08:27 AM
Hey Ingrid,
Just curious as to your progress on this...we to would love to have a modified widget that displays the subcategories on the KB.
Thanks,
ML
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2017 03:21 AM
Hi Marc! sorry for late reply. anyway, no sorry didn't get any way on this . was hoping for some help here, since I am no scripting expert.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-23-2017 02:06 PM
THANK YOU for making this! This saved us so much time and headache!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-23-2017 05:13 AM
Hi Sudharsan! did you manage to replicate the tree structure to service Portal?