CMDBUtil - Global

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.

This example creates a CMDBUtil object.
var cu = new SNC.CMDBUtil();
cu.baselineProposedChangesGenDIFF(current, action.get('sysparm_changeset'));
This example calls a static method.
var output = SNC.CMDBUtil.getAllChildrenOfAsCommaList('cmdb_ci_computer');

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.

Table 1. Parameters
Name Type Description
proposedChanges GlideRecord The collection of proposed changes in the change request (CHG).
Table 2. Returns
Type Description
void
//Where current is a GlideRecord and action is the current UI action
var base = new SNC.CMDBUtil();
base.baselineProposedChangesApplyChanges(current);

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.

Table 3. Parameters
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.
Table 4. Returns
Type Description
void
//Where current is a GlideRecord and action is the current UI action
var base = new SNC.CMDBUtil();
base.baselineProposedChangesGenDIFF(current, action.get('sysparm_changeset'));

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.

Table 5. Parameters
Name Type Description
dictFile String The file name including path, of the dictionary to load.
Table 6. Returns
Type Description
void

CMDBUtil - createCIRelationship(String tableName, String parentField, String childField, String parentDesc, Object childDesc)

Creates the specified CI relationship using the specified invocation parameters.

If called without the first parameter, passing only four parameters, defaults to the CI Relationship [cmdb_rel_ci] table.

This is a dynamic method.

Table 7. Parameters
Name Type Description
tableName String The table name
parentField String The parent field
childField String The child field
parentDesc String The parent relationship descriptor
childDesc Object The child relationship descriptor
Table 8. Returns
Type Description
void

CMDBUtil - getAllChildrenOfAsCommaList(String baseTable)

Gets all the child tables of the specified table as a comma-separated list.

This is a static method.

Table 9. Parameters
Name Type Description
baseTable String The base table name.
Table 10. Returns
Type Description
String A comma-separated list of sys_ids of tables extending the base table.
//Where cmdv_ci_computer is a table.
var output = SNC.CMDBUtil.getAllChildrenOfAsCommaList('cmdb_ci_computer');
gs.print(output);

CMDBUtil - getCMDBViews()

Gets all the records in the CMDB View [cmdb_view] table.

This is a dynamic method.

Table 11. Parameters
Name Type Description
None
Table 12. Returns
Type Description
Array List The records in the CMDB view table.

CMDBUtil - getTables(String tableName)

Gets a list of all the parents of a table.

This is a static method.

Table 13. Parameters
Name Type Description
tableName String The table name
Table 14. Returns
Type Description
ArrayList List of tables that are parents of the specified table.

CMDBUtil - processCIChange(GlideRecord event, GlideRecord target)

Wraps the call to RelationshipEventProcessor(), which processes any changes to CI relationships.

This is a dynamic method.

Table 15. Parameters
Name Type Description
event GlideRecord The event record.
target GlideRecord The target record.
Table 16. Returns
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.

Table 17. Parameters
Name Type Description
event GlideRecord The event record
current GlideRecord The current record, which is either the relation record or a user record if the current process is a deletion.
relType String The type of relation that changed.
triplet String The child, parent, and class name from the relation that changed.
Table 18. Returns
Type Description
void

CMDBUtil - removeCIRelationship(String tableName, String parentField, String childField, String parentDesc, Object childDesc)

Deletes the specified CI relationship.

If called without the first parameter, passing only four parameters, defaults to the CI Relationship [cmdb_rel_ci] table.

This is a dynamic method.

Table 19. Parameters
Name Type Description
tableName String The table name
parentField String The parent field
childField String The child field
parentDesc String The parent relationship descriptor
childDesc Object The child relationship descriptor
Table 20. Returns
Type Description
void

CMDBUtil - reParentTable(String table, String oldParent, String newParent)

Changes the parent of the given table to the new parent.

This is a static method.

Table 21. Parameters
Name Type Description
table String The table to re-parent
oldParent String The old parent
newParent String The new parent
Table 22. Returns
Type Description
Boolean True, if successful; otherwise, false.