Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
(function executeRule(current, previous /*null when async*/) {

var analyzer = new CrossTableDependencyAnalyzer();
var deps = analyzer.getDependencies(current);

if (deps.length > 0) {
var messages = deps.map(function(d){ return d.table + ': ' + d.number + ' (' + d.state + ')'; });
current.comments = 'Potential impact on related records:\n' + messages.join('\n');
}

})(current, previous);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
The Cross-Table Dependency Analyzer is a custom ServiceNow solution designed to dynamically detect and analyze dependencies across multiple tables such as Incidents, Problems, Changes, and Configuration Items (CIs). This tool ensures that updates to one record do not inadvertently impact related records across the system, providing better visibility, risk mitigation, and proactive management.

Unlike out-of-the-box (OOB) impact analysis, this solution is fully customizable, real-time, and developer-driven, making it suitable for organizations with complex IT processes or interdependent services.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
var CrossTableDependencyAnalyzer = Class.create();
CrossTableDependencyAnalyzer.prototype = {
initialize: function() {},

// Get related records for a CI or task
getDependencies: function(record) {
var dependencies = [];

if (!record) return dependencies;

var ciId = record.cmdb_ci; // for incidents or changes
if (ciId) {
// Find active incidents for this CI
var inc = new GlideRecord('incident');
inc.addQuery('cmdb_ci', ciId);
inc.addActiveQuery();
inc.query();
while (inc.next()) {
dependencies.push({
table: 'incident',
number: inc.number.toString(),
state: inc.state.toString()
});
}

// Find active changes for this CI
var chg = new GlideRecord('change_request');
chg.addQuery('cmdb_ci', ciId);
chg.addActiveQuery();
chg.query();
while (chg.next()) {
dependencies.push({
table: 'change_request',
number: chg.number.toString(),
state: chg.state.toString()
});
}

// Find problems linked to this CI
var prb = new GlideRecord('problem');
prb.addQuery('cmdb_ci', ciId);
prb.addActiveQuery();
prb.query();
while (prb.next()) {
dependencies.push({
table: 'problem',
number: prb.number.toString(),
state: prb.state.toString()
});
}
}

return dependencies;
},

type: 'CrossTableDependencyAnalyzer'
};
Loading