How can I make KB categories and subcategories with the order i want in Tokyo?

Wing Lee1
Tera Contributor

I have read and try some way which many people is asking / sharing on internet like this.

Unfortunately, the ways provided were all failed in my instance.

Below screen capture is what I want.

But it always goes
- KB Categories

     - Sub Cat.

          - Cat. A

          - Cat. B

          - Others

          - Report

          - TimeSheet

     - ITSM

 

Please help!

Thank you.

 

WingLee1_0-1675924814221.png

 

3 REPLIES 3

newhand
Mega Sage

HI@Wing Lee1 

I read the link you posted .

I think it really can slove your problem.

 

If you failed .  please check 

1.   did you modify the right widget ?

2.   if the widget can't be modified directly ,  you need to clone it and modify the cloned one ,then replace the cloned one to the page.

      and if the page using the widget can't be modified directly ,

      you need to clone the page and replace the widget with the cloned one, and then modify the link to the new page.

 

 

      

 

      

Please mark my answer as correct and helpful based on Impact.

Wing Lee1
Tera Contributor

Hi newhand,

 

Thank you for replying.

I did clone the widget (KB Categories - KBv3) and edit the page with the cloned widget.

But it's not working.

 

 

WingLee1_1-1676252051692.png

 

And below is Server Script and HTML Script

Server Script :

WingLee1_2-1676252191544.png

 

 

HTML Script :

WingLee1_3-1676252386717.png

 

HI@Wing Lee1 

I read the codes , and find that the place you modified just effects on the top level  categories.

You also need to change the sort for the sub categories.

 

serve-side script  Line : 145 ~

 

var subcategories = new GlideRecord("kb_category");
subcategories = $sp.getSubCategories(cats.getUniqueValue());

// I can't find any information about $sp.getSubCategories,

//  But i guess the results is GlideRecord, have a try to use a  normal query with sort instead of this line.


categoryDetails.subcategories = [];
while (subcategories.next()) {
var category = getCategory(subcategories, level+1);
if (category.count != 0) {
categoryDetails.subcategories.push(category);
}
categoryDetails.showChildren = categoryDetails.showChildren || category.showChildren;
}

 

 

 

Please mark my answer as correct and helpful based on Impact.