Solved: Change display Order of Knowledge base articles on... - ServiceNow Community

Change display Order of Knowledge base articles on service portal

markalpine
Kilo Expert

We are using Jakarta.

I need the articles I create for a KB to display on the service portal with the newest articles displaying first.

Currently they seem to display alphabetically (a to z).

This is just for the service portal side of things.

Here's what we get now...
find_real_file.png

 

Thanks

1 ACCEPTED SOLUTION

Good that you found the solution!
Yeah, it's just adding a dash before to make it descending when setting order in angular.

The problems with differing time zones, you see the community updates at the wrong time.

View solution in original post

13 REPLIES 13

felladin
Tera Guru

Hello,

I tried to find if there was an Order By OOB in the widgets, but I'm not able to find one at the moment.
We did this to the Simple List widget, though:
Add an option to the Option Schema: {"name":"order_by","label":"Order by","type":"field_name"}
In that we fill in what field should be used as ordering.

Then we use that in query running for the results. Works so far.
Also added an ordering in the Angular ng-repeat, but that code is lost in the mists.

Regards
Anton

markalpine
Kilo Expert

Thank you for the reply. I think your a bit over my newbie head on this subject.

I'm pretty sure this is similar to the code I need:

kb.orderByDesc('sys_view_count');

 

but I need to change it from view count to created date or published date.

 

Any ideas?

Thanks

Mark Stanger
Giga Sage

As Anton mentioned, you'll likely need to clone the widget and then edit the widget option schema to create a widget with the effect you're looking for.  Then you'll need to add your new widget to the page in place of the existing one (or create a new page entirely).  You'll need to do this (or configure other options if available depending on the widget) for every widget where you want the results to be sorted this way.  Here's how you could do this for the 'KB Category Page' widget shown in your screenshot.

1)  Clone the widget as shown here...

https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/build/service-portal/task/t_CloneAndEditAWidget.html

2)  Adjust your 'HTML Template' and 'Server Script' sections as shown in this screenshot and save...

find_real_file.png

3)  Edit the option schema for your new widget as explained in this article and as shown in the following screenshot...

https://docs.servicenow.com/bundle/jakarta-servicenow-platform/page/build/service-portal/task/edit-option-schema.html

find_real_file.png

5)  When you configure your widget options use '-published' to sort the KB results from newest to oldest for each category selected.

markalpine
Kilo Expert

HI just told me this cannot be done and I need to Activate "Knowledge Management Service Portal" plugin to accomplish this.

 

Are both the answers here and from HI correct?