- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 06:03 AM
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...
Thanks
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-26-2018 10:11 PM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 06:38 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 07:18 AM
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 as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 07:48 AM
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...
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
5) When you configure your widget options use '-published' to sort the KB results from newest to oldest for each category selected.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-25-2018 08:19 AM
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?