How to build a tree view in ServiceNow
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2020 12:05 PM
Hi All,
I am new to ServiceNow. How to build a tree view widget in ServiceNow from scratch?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2020 01:11 PM
Did you check link? This has an update set as well that can be downloaded & altered as per need.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-02-2020 02:02 PM
Hi
You can also use an external js library to build a tree-view. This one is simple and easy to implement https://github.com/jonmiles/bootstrap-treeview.
All you'd have to do is to add the library's js code to a js include, and then add it to your widget as widget dependency. (Refer this for adding widget dependency: https://community.servicenow.com/community?id=community_article&sys_id=78cb624fdb5edbc0fc5b7a9e0f961...).
This library works really well, and all you'd have to do is to pass the data attribute of the tree-view, using either a static json, or GlideRecord query, using a recursive function.
I've used it in one of my projects, and it works really well, and gives you functionalities like search, highlighting the search results, setting the node & expand collapse icons etc. as well.
Thanks & Regards,
Rishabh Jha