About Dependency type(ngbsm_script)of Dependency view
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 05:37 PM
The usage of Dependency type (ngbsm_script) in Dependency view is unknown.
It says that you can generate custom views, but for example, is it possible to do the following?
example)
・If an incident is linked to a CI, the corresponding CI will be displayed in red in the dependency view.
If possible, could you please provide an example script?
thank you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2025 10:03 PM
Hi @kanakoA
We can verify with the customize the Dependency View in ServiceNow using scripts and the ngbsm_script dependency type. You can leverage the ngbsm_script to modify how CIs are represented in the Dependency View, such as changing their color based on certain conditions (e.g., incidents linked to the CI).
Take reference of below script include:
var CIIncidentChecker = Class.create();
CIIncidentChecker.prototype = {
initialize: function() {},
isIncidentLinkedToCI: function(ciSysId) {
var incidentGR = new GlideRecord('incident');
incidentGR.addQuery('cmdb_ci', ciSysId);
incidentGR.addQuery('active', true);
incidentGR.query();
return incidentGR.hasNext();
}
};
The appearance of the CI in the Dependency View will be modify with help of below client script.
(function() {
var ciSysId = g_item.sys_id;
var ciChecker = new CIIncidentChecker();
var isLinkedToIncident = ciChecker.isIncidentLinkedToCI(ciSysId);
if (isLinkedToIncident) {
g_item.setStyle("background-color", "yellow");
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-04-2025 02:43 AM
Thanks for your suggestion.
Is it correct to put the two scripts provided into one ngbsm_script record?