The CreatorCon Call for Content is officially open! Get started here.

About Dependency type(ngbsm_script)of Dependency view

kanakoA
Tera Contributor

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.

2 REPLIES 2

Nilesh Pol
Tera Guru
Tera Guru

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");
}
})();

kanakoA
Tera Contributor

@Nilesh Pol 

Thanks for your suggestion.
Is it correct to put the two scripts provided into one ngbsm_script record?