how to show tree selection values with following criteria?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 06:30 AM
Hi all,
Tree Structure:
Root = Global
Node 0 = Country
Node 1 = Sites
Table is "Location"
Only values in Node 1 will be saved in "Location". Node 0 and Root will be used as a helper to automatically select values within its hierarchy. Selecting Root will automatically select ALL Node 0 and Node 1 values within its hierarchy. Selecting a Node 0 value will automatically select all Node 1 values within its hierarchy. De-selecting a Node 1 value de-selects its corresponding Node 0 and Root, if applicable. When reopening the Catalog Item, the tree selections will only show currently saved locations.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 07:07 AM
So what exactly are you asking? How to display this? What to build to display this? Something else?
If you are asking how do display it you are going to have to build a UI Macro for the platform interface and a widget for the Service Portal. Then add a Macro var to your catalog item.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2022 01:01 AM
My question was how to display this. And also is it possible to store these value in variable and next time when the same user opens the catalog item the variable has to show the previous value he has selected. Is it possible?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2022 08:17 AM
It is, like
The "Custom" (It was Macro in older versions) var type allows you set a UI Macro and a Widget to use. UI Macro for the platform interface and Widget for the Service Portal interface. It provides a place to store some text data. So to store the selections you convert your data to a text format using JSON or other method and then store it using something like the below if its a SP Widget.
if(typeof $scope.page.g_form != "undefined"){
$scope.page.field.value = JSON.stringify(dataToStore);
}
When the widget loads you can just check the above location to see if there is a value and if so use that to render the widget.
For the UI Macro I believe you can just use g_form.setValue to store the information but the load will need to be done in the Jelly.
So with all of that said if you can use the tree picker then do so and you will have one value stored in a reference field.
If you need to use user preferences but I do not think you do.
http://www.john-james-andersen.com/blog/service-now/servicenow-user-preferences-server-client-access.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2022 09:16 AM
To make a field display an hierarchical collection of records as a tree, simply add "tree_picker=true" as an attribute to the field referencing the Location table. The rest of this should be achievable by structuring your data properly in the Location table.