CMDBUtil - Global
-
- UpdatedFeb 1, 2024
- 7 minutes to read
- Washington DC
- API reference
The CMDBUtil API provides utility methods for creating and managing table relationships in the Configuration Management Database (CMDB) and managing CMDB baselines.
CMDBUtil is a JavaScript-accessible ScriptableObject. The CMDBUtil API has dynamic and static methods. You access dynamic methods by creating a SNC.CMDBUtil object. You access static methods by using SNC.CMDBUtil global object to call the methods.
Use these methods to manage CMDB table relationships and baselines.
CMDBUtil - baselineProposedChangesApplyChanges(GlideRecord proposedChanges)
Applies proposed changes in a task_ci record that represent an update set for all CIs associated with the task.
This is a dynamic method.
Name | Type | Description |
---|---|---|
proposedChanges | GlideRecord | The collection of proposed changes in the change request (CHG). |
Type | Description |
---|---|
void |
Example
CMDBUtil - baselineProposedChangesGenDiff(GlideRecord current, String changeSet)
Generates the XML for proposed changes diff, and adds it to the corresponding task_ci record.
This is a dynamic method.
Name | Type | Description |
---|---|---|
current | GlideRecord | The GlideRecord that contains the collection of proposed changes. |
changeSet | String | The sysid of the task_ci record that represents the change set to use. |
Type | Description |
---|---|
void |
Example
CMDBUtil - bootstrap(String dictFile)
Bootstraps the environment by creating the database, creating the system dictionary table, and having the system dictionary table describe itself.
This is a static method.
Name | Type | Description |
---|---|---|
dictFile | String | The file name including path, of the dictionary to load. |
Type | Description |
---|---|
void |
CMDBUtil - createCIRelationship(String tableName, String parent, String child, String parentField, String childField)
Creates a CI relationship between fields.
Type | Description |
---|---|
String | Sys_id of the new record listed in the CI Relationship [cmdb_rel_ci] table. |
Example
The following example shows how to create a CI relationship between the parent CI contains field and the child CI contained_by field. The relationship is listed in the CI Relationship [cmdb_rel_ci] table.
CMDBUtil - getAllChildrenOfAsCommaList(String baseTable)
Gets all the child tables of the specified table as a comma-separated list.
This is a static method.
Name | Type | Description |
---|---|---|
baseTable | String | The base table name. |
Type | Description |
---|---|
String | A comma-separated list of sys_ids of tables extending the base table. |
Example
CMDBUtil - getCMDBViews()
Gets all the records in the CMDB View [cmdb_view] table.
This method is dynamic.
Name | Type | Description |
---|---|---|
None |
Type | Description |
---|---|
Array | List of the records in the CMDB View [cmdb_view] table. |
Example
The following example shows how to list the CMDB views.
Output:
CMDBUtil - getTables0(String tableName)
Gets a list of all the parents of a table.
This method is a static method.
Name | Type | Description |
---|---|---|
tableName | String | The table name. |
Type | Description |
---|---|
Array | List of tables that are parents of the specified table. |
Example
The following example shows how to list the parent tables of the Server [cmdb_ci_server] table.
Output:
CMDBUtil - isExcludedFromBR(String className)
Determines whether a CI class is defined in the Business Rule Exclusion Lists [cmdb_business_rule_exclusions] table. Use this method in an advanced condition to prevent a business rule from executing on excluded CI classes.
For example, the Create Asset on insert business rule uses this method in the advanced condition to prevent the rule from creating assets for CI classes such as cmdb_ci_qualifier, cmdb_ci_endpoint, cmdb_ci_storage_volume, and cmdb_ci_vcenter_datastore_disk. Define classes for exclusion in the Business Rule Exclusion Lists [cmdb_business_rule_exclusions] table.
Name | Type | Description |
---|---|---|
className | String | Name of the class to check for exclusion. |
Type | Description |
---|---|
Boolean | True if the class is defined in the Business Rule Exclusion Lists [cmdb_business_rule_exclusions] table; otherwise, false. |
Example
CMDBUtil - processCIChange(GlideRecord event, GlideRecord target)
Wraps the call to RelationshipEventProcessor(), which processes any changes to CI relationships.
This is a dynamic method.
Name | Type | Description |
---|---|---|
event | GlideRecord | The event record. |
target | GlideRecord | The target record. |
Type | Description |
---|---|
void |
CMDBUtil - processRelChange(GlideRecord event, GlideRecord current, String relType, String triplet)
Wraps the call to RelationshipEventProcessor(), which processes any changes to CI relationships, with the specified type and triplet.
This is a dynamic method.
Type | Description |
---|---|
void |
CMDBUtil - removeCIRelationship(String tableName, String parentField, String childField, String parentDesc, Object childDesc)
Deletes the specified CI relationship.
This is a dynamic method.
Type | Description |
---|---|
void |
Example
This code example shows how to remove every relation type 'Depends on::Used by' for the specified parent.
CMDBUtil - reParentTable(String table, String oldParent, String newParent)
Changes the parent of the given table to the new parent.
This method is a static method.
Name | Type | Description |
---|---|---|
table | String | The table to re-parent. |
oldParent | String | The old parent. |
newParent | String | The new parent. |
Type | Description |
---|---|
Boolean | Flag that indicates if the parent change is successful. Valid values:
|
Example
To recreate the following example, use the code provided to create a custom table. Next create a record and check it in the task table. The custom table created extends from the Task table, which means it has successfully re-parented. The code isn't intended to be directly used via copy and paste. To show output, the custom table was created before running the code.
Output:
On this page
- CMDBUtil - baselineProposedChangesApplyChanges(GlideRecord proposedChanges)
- CMDBUtil - baselineProposedChangesGenDiff(GlideRecord current, String changeSet)
- CMDBUtil - bootstrap(String dictFile)
- CMDBUtil - createCIRelationship(String tableName, String parent, String child, String
parentField, String childField)
- CMDBUtil - getAllChildrenOfAsCommaList(String baseTable)
- CMDBUtil - getCMDBViews()
- CMDBUtil - getTables0(String tableName)
- CMDBUtil - isExcludedFromBR(String className)
- CMDBUtil - processCIChange(GlideRecord event, GlideRecord target)
- CMDBUtil - processRelChange(GlideRecord event, GlideRecord current, String relType, String
triplet)
- CMDBUtil - removeCIRelationship(String tableName, String parentField, String childField,
String parentDesc, Object childDesc)
- CMDBUtil - reParentTable(String table, String oldParent, String newParent)