Expanding out sub categories in the SC Category widget in the Service catalog

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2018 12:42 PM
I am attempting to expand parent sub-categories in the SC Category widget in the Service Catalog. Has anyone accomplished this? Below are screenshots of what the SC Category widget looks like now by default on the left and what I would like too accomplish for the default view on the right.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2018 03:50 PM
You can have look into OOB widget available for hierarchical widget code.
https://docs.servicenow.com/bundle/kingston-servicenow-platform/page/build/service-portal/concept/org-chart-widget.html
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2019 05:47 AM
2. In the server script, replace the line
categoryDetails.showChildren = (categoryDetails.sys_id === categoryId);
by
categoryDetails.showChildren = (categoryDetails.sys_id === categoryId || categoryDetails.sys_id == '<sys_id of the category you to expand by default>');
e.g.
//XHU 04/01/18 - Always Display children of category "Service Utilisateur" - 95ff5835dbbfe60084e7bc2ffe9619aa
categoryDetails.showChildren = (categoryDetails.sys_id === categoryId || categoryDetails.sys_id == '95ff5835dbbfe60084e7bc2ffe9619aa');
Before I perform the modification, the categories are all collapsed when I go to the service catalog homepage
After I have performed the 2 steps described aboved, the category "Service Utilisateur" is expended by default when I go to the service catalog homepage
Since is not much recommend to hardcode sys_id in the script, I would even go further to put the category sys_id as an instance options of the widgets.
Ximizu
Co-founder of CloudSpirit