- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2019 12:27 AM
Hi All,
I have a system property that has value stored like :
{"US":"United States","CN":"China","CA":"Canada","JP":"Japan"}
I want to access this System property in a script include where the condition needs to be checked as if the Key is 'US', Value should be returned and 'United States'.
Very new to system properties. Could you all please help me how to resolve this?
Thank you.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2019 12:49 AM
Here is an example using an OOTB System Property with code run in Xplore
System Property Value
{"REPORT" : "book","MAP" : "image","HOMEPAGE" : "home","SURVEY" : "form","ASSESSMENT" : "form","TIMELINE" : "calendar","SCRIPT" : "script","LIST" : "list","DETAIL" : "book-open","NEW" : "add","SEARCH" : "search","LABEL" : "label","HTML" : "script","DIRECT" : "view","NULL" : "help"}
Script
var index = 'REPORT';
var props = gs.getProperty('glide.ui.nav.type_icon_map');
var hashMap = JSON.parse(props); // Add global prefix if in scope
var answer = hashMap[index];
answer;
Output
book
Replace the system property with your own and the appropriate error checking and you should be good.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2019 12:49 AM
Here is an example using an OOTB System Property with code run in Xplore
System Property Value
{"REPORT" : "book","MAP" : "image","HOMEPAGE" : "home","SURVEY" : "form","ASSESSMENT" : "form","TIMELINE" : "calendar","SCRIPT" : "script","LIST" : "list","DETAIL" : "book-open","NEW" : "add","SEARCH" : "search","LABEL" : "label","HTML" : "script","DIRECT" : "view","NULL" : "help"}
Script
var index = 'REPORT';
var props = gs.getProperty('glide.ui.nav.type_icon_map');
var hashMap = JSON.parse(props); // Add global prefix if in scope
var answer = hashMap[index];
answer;
Output
book
Replace the system property with your own and the appropriate error checking and you should be good.
ServiceNow Nerd
ServiceNow Developer MVP 2020-2022
ServiceNow Community MVP 2019-2022
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2019 03:03 AM
Hi Paul,
The above solution worked fine for one scenario. Thank You for this. However for one more scenario, I need to get the reverse. Means if I give input as "book", output should be "Report" as per your example and we need to maintain this one System property.
Please let me know how it can be done.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2019 03:30 AM
Hi,
Note: Please mark reply as helpful if it has answered your 2nd question
var props = gs.getProperty('glide.ui.nav.type_icon_map');
var hashMap = JSON.parse(props); // Add global prefix if in scope
for ( var v in hashMap ) {
if ( hashMap[v] == 'book' ) {
return v; // this will give you the first ocurrence of key
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-24-2019 04:46 AM
It worked! Thank You.