Setting Tree picker for a reference variable doesnt work properly in the service portal page

ajaypradeep
Kilo Contributor

HI,

I created a catalog item variable of reference type, which reference to one of the custom tables I have. I set the Tree Picker for variable by setting the variable attribute with tree_picker=true. However, it is working fine in service catalog homepage. But, when viewed from the service portal page the entries are still listed out as drop down option and not in the tree hierarchy.

On Portal page,

Portal Page.png

On catalog homepage,

Catalog Home page.png

Please let me know how to get over this issue.

Thanks,

Ajay Pradeep

12 REPLIES 12

larstange
Mega Sage

Hi



You will have to design your own widget to get that functionality in Service Portal.


I have attached a version i am using.


It is showing departments, but should be easy to modify to show data from another table


find_real_file.png



When the user selects a department is it is added to a list collector varaible on the catalog item. You can modify the widget if you only want to allow the user to select 1 department.




  1. First Import the the "widget.department_picker.xm" using X-loader. It will load necessary dependencies (GitHub - service-portal/x-loader: Easy way to import pages and widgets into Service Portal
  2. The import the update set "sys_remote_update_set_Department Picker.xml". It will add a demo catalog item called "Demo Department Picker"

I have added the widget to share as well - ServiceNow Share


Another option is to use jsTree ( https://www.jstree.com/ ). The solution is similar to the previous solution provided by Lars but I found it easier to implement.



tree.jpg


can it select the full path