Skip to content

Commit 840009f

Browse files
authored
Get CI Relationships associated with specific CMDB CI record. (#1431)
1 parent 190c132 commit 840009f

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Retrieve CI Relationships present for particular CMDB CI record
2+
This functionality allows users to obtain all configuration item (CI) relationships associated with a specific CMDB CI record. It provides detailed insights into how the selected CI is related to other CIs within the CMDB, enabling better management and understanding of infrastructure dependencies.
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
var cmdb_class_name = "<cmdb_ci_class_name>"; // Replace with your cmdb_table_name
2+
var record_sys_id = "<cmdb_ci_record_sys_id>"; // Replace with your cmdb_ci record sys_id
3+
4+
var request = new sn_ws.RESTMessageV2();
5+
request.setHttpMethod('get');
6+
request.setEndpoint('https://<instance_name>.service-now.com/api/now/cmdb/instance/' + cmdb_class_name + "/" + record_sys_id);
7+
request.setBasicAuth('<instance_username>', '<instance_password>'); // Replace with your instance username and password
8+
var response = request.executeAsync();
9+
response.waitForResponse(60);
10+
11+
if (response.getStatusCode() == 200) {
12+
var body = JSON.parse(response.getBody());
13+
gs.info("Inbbound Relationships: " + JSON.stringify(body.result.inbound_relations));
14+
gs.info("Outbound Relationships: " + JSON.stringify(body.result.outbound_relations));
15+
} else {
16+
gs.error("Error in API Response with statusCode: "+ response.getStatusCode())
17+
}

0 commit comments

Comments
 (0)