|
| 1 | +# ServiceNow Automatic Relationship Builder |
| 2 | +**Auto-create CMDB relationships dynamically on CI insert or update** |
| 3 | + |
| 4 | +--- |
| 5 | + |
| 6 | +## Overview |
| 7 | + |
| 8 | +The **Automatic Relationship Builder** ensures that your CMDB stays complete and accurate by automatically creating parent–child relationships between Configuration Items (CIs) whenever they are inserted or updated. |
| 9 | + |
| 10 | +Instead of manually linking servers, applications, and databases, this Business Rule dynamically establishes **"Runs on"**, **"Depends on"**, or **"Connected to"** relationships based on CI attributes. |
| 11 | + |
| 12 | +--- |
| 13 | + |
| 14 | +## Key Highlights |
| 15 | + |
| 16 | +Builds CMDB relationships automatically |
| 17 | +Eliminates manual linking of dependent CIs |
| 18 | + |
| 19 | +--- |
| 20 | + |
| 21 | +## Use Case |
| 22 | + |
| 23 | +When a new **Application CI** is created or discovered and its **host CI (server)** is known, |
| 24 | +the script automatically builds a relationship of type **“Runs on::Runs”** between the two. |
| 25 | + |
| 26 | +This keeps your CMDB up-to-date without human intervention. |
| 27 | + |
| 28 | +--- |
| 29 | + |
| 30 | +## Table and Trigger |
| 31 | + |
| 32 | +| Item | Value | |
| 33 | +|------|-------| |
| 34 | +| **Table** | `cmdb_ci_appl` | |
| 35 | +| **Trigger** | After Insert / After Update | |
| 36 | +| **Condition** | `u_host` field is populated | |
| 37 | +| **Purpose** | Create a “Runs on” relationship between host and application | |
| 38 | + |
| 39 | +--- |
| 40 | + |
| 41 | +## Script — Business Rule |
| 42 | + |
| 43 | + |
| 44 | +Business Rule: Auto Relationship Builder |
| 45 | +Table: cmdb_ci_appl |
| 46 | +When: after insert / after update |
| 47 | + |
| 48 | +## Example Input (New CI Record) |
| 49 | +| Field | Value | |
| 50 | +| ------ | ---------------------------- | |
| 51 | +| Name | Payroll Application | |
| 52 | +| Class | Application (`cmdb_ci_appl`) | |
| 53 | +| u_Host | APP-SERVER-01 | |
| 54 | +| Owner | IT Operations | |
| 55 | + |
| 56 | +## Example Output (Created Relationship) |
| 57 | + |
| 58 | +| Field | Value | |
| 59 | +| ------ | ------------------- | |
| 60 | +| Parent | APP-SERVER-01 | |
| 61 | +| Child | Payroll Application | |
| 62 | +| Type | Runs on :: Runs | |
| 63 | +| Table | cmdb_rel_ci | |
| 64 | +Relationship automatically visible in CI Relationship Viewer. |
| 65 | + |
| 66 | + |
0 commit comments