Expanding nested categories in Service Portal by default

aaronbartosch
Tera Contributor

On our Service Portal I have a requirement that Nested categories be expanded by default So that you do NOT have to click the little folder icon to expand the sub categories.

nested cats.png

Has anyone been able to figure this out?

8 REPLIES 8

dansieders
Tera Expert

Hey Everyone,

Looks like ServiceNow has updated their Service Catalogue, Categories widget in Kingston;

find_real_file.png

 

Cheers Dan

yashlimviya
Kilo Contributor

Please open the page editor - click on the edit button of SC categories widget - select the category layout has Flat. PFA.

 

Ximizu
Mega Guru
Hi bretelson_patrick@bah.com,
 
You can achieve this in 2 steps:
 
1. Clone the widget "SC Category"
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

find_real_file.png

 

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

find_real_file.png

 

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

This worked perfectly!  Thanks!