- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2025 06:52 AM - edited ‎08-05-2025 11:36 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2025 08:10 AM
The JSON structure is designed to be easily parsable by a script that would calculate the risk.
criticalServicesZero: This array groups all the rules for when the script identifies zero critical services at Depth 1/2.
criticalServicesOneOrMore: This array groups all the rules for when the script identifies one or more critical services at Depth 1/2.
infrastructureCIOnly: This object handles the specific edge case where the record has an infrastructure CI but no related impacted services, assigning a fixed risk score.
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2025 07:10 AM
but what to put in property ? what mapping?
Example: consider I want to map assignment group with location so in system property I will store like this
Then I can easily get the location associated to that group using this background script
Something similar you can also do
[
{
"group": "acme",
"location": "India"
},
{
"group": "support desk",
"location": "Australia"
}
]
Script:
// JSON object as a string (usually stored in a property)
var groupLocationJson = [
{
"group": "acme",
"location": "India"
},
{
"group": "support desk",
"location": "Australia"
}
];
// ---- FUNCTION TO GET LOCATION BY GROUP NAME ----
function getLocationByGroup(groupName) {
for (var i = 0; i < groupLocationJson.length; i++) {
if (groupLocationJson[i].group.toLowerCase() === groupName.toLowerCase()) {
return groupLocationJson[i].location;
}
}
return null; // not found
}
// ---- EXAMPLE USAGE ----
var groupName = "support desk"; // Replace with input as needed
var location = getLocationByGroup(groupName);
gs.info('Group: ' + groupName + ', Location: ' + location);
Output:
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2025 07:18 AM
Hello @pratyusha11
Your system property will be as per below screenshot:
Your value of property will be as showcased below.
{
"criticalServicesZero": [
{"totalCIs": "1-4", "risk": 200},
{"totalCIs": "5-9", "risk": 200},
{"totalCIs": "10-30", "risk": 300},
{"totalCIs": "31-100", "risk": 400},
{"totalCIs": "101+", "risk": 500}
],
"criticalServicesOneOrMore": [
{"totalCIs": "1-4", "risk": 500},
{"totalCIs": "5-9", "risk": 1000},
{"totalCIs": "10-30", "risk": 1000},
{"totalCIs": "31-100", "risk": 1000},
{"totalCIs": "101+", "risk": 1000}
],
"infrastructureCIOnly": {
"risk": 1000
}
}
Now when we try to use this property in background script with below code you can use value from it.
var gr_prop_JSON_value = gs.getProperty('property_test');
var riskConfig = JSON.parse(gr_prop_JSON_value);
// Now you can access the data, for example:
var riskValue = riskConfig.criticalServicesZero[0].risk;
gs.print(riskValue); // this will give output as 200.
var totalCIs = riskConfig.criticalServicesZero[0].totalCIs;
gs.print(totalCIs ); // this will give output as 1-4.
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2025 07:33 AM
How to configure 'depth' here ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-05-2025 08:10 AM
The JSON structure is designed to be easily parsable by a script that would calculate the risk.
criticalServicesZero: This array groups all the rules for when the script identifies zero critical services at Depth 1/2.
criticalServicesOneOrMore: This array groups all the rules for when the script identifies one or more critical services at Depth 1/2.
infrastructureCIOnly: This object handles the specific edge case where the record has an infrastructure CI but no related impacted services, assigning a fixed risk score.
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.