CIData - Global

Utility class for working with CI data structures in JavaScript.

Instances of this class represent a CI (both its base record and any related lists), and the provided methods allow loading from or storing both the base record and related lists.

This class acts as a container for simple classes acting as maps of property name/value pairs. This class contains three kinds of such maps.
  • A single map representing the base CI table entry (such as one row cmdb_ci_linux_server and its superclasses). This map can be retrieved with the getData() method.
  • Arrays of maps representing the instances of related lists, with each array representing a single related list and each element of such an array representing a single row of that related list. These arrays can be retrieved with the getRelatedList() method.
  • Arrays of maps representing the instances of many-to-many tables, with each array representing a single many-to-many table and each element of such an array representing a single row of that many-to-many table. These arrays can be retrieved with the getM2MTable() method.

Use with any server-side discovery script.

CIData - addRelatedList(Array relatedList)

Adds the specified related list to this instance.

Table 1. Parameters
Name Type Description
relatedList Array The related list
Table 2. Returns
Type Description
void


      
    

CIData - CIData(String debugFlag)

Creates an instance of the CIData class.

Table 3. Parameters
Name Type Description
debugFlag String True if debug logging is enabled.


      
    

CIData - convertRelatedList(String sensor, String tableName, String refField, String keyName)

Converts the specified related list to a related list in a given sensor.

Table 4. Parameters
Name Type Description
sensor String The sensor
tableName String The table name
refField String The reference field
keyName String The key name
Table 5. Returns
Type Description
void


      
    

CIData - fromXML(String xml)

Initializes the current CIData instance from the specified XML string.

Table 6. Parameters
Name Type Description
xml String An XML string
Table 7. Returns
Type Description
void


      
    

CIData - getData()

Gets the data map in the base CI record.

Table 8. Parameters
Name Type Description
None
Table 9. Returns
Type Description
Object The data map


      
    

CIData - getM2MTable(String table, String refField)

Gets an array of data maps in the given many-to-many list (to this CI).

The array is not in any particular order. If this is not a many-to-many list, returns an empty array.

Table 10. Parameters
Name Type Description
table String The name of the table containing the related list. In the case of a many-to-many list, this is the name of the many-to-many table, not the target table.
refField String The name of the field in the related list that refers to this CI. In the case of a many-to-many list, this is the name of the referring field in the many-to-many table, not in the target table.
Table 11. Returns
Type Description
Array an array of data maps in the given many-to-many list. If this is not a many-to-many list, returns an empty array.


      
    

CIData - getRelatedList(String table, String refField)

Gets an array of maps of data in the given related list (to this CI).

The array is not in any particular order. In the case of a many-to-many list, this will be an array of instances of the target table, not the many-to-many table. For example, given 'cmdb_software_instance' and 'installed_on' (a many-to-many table and the field that refers to a CI), this method will return an array of maps representing cmdb_ci_spkg (the target table) instances.

Table 12. Parameters
Name Type Description
table String Name of the table containing the related list. In the case of a many-to-many list, this is the name of the many-to-many table, not the target table.
refField String Name of the field in the related list that refers to this CI. In the case of a many-to-many list, this is the name of the referring field in the many-to-many table, not in the target table.
Table 13. Returns
Type Description
Array An array of maps of data in the specified related list.


      
    

CIData - getRelatedListInstance(String table, String refField)

Returns the instance of CIRelatedList for the given list.

Table 14. Parameters
Name Type Description
table String Name of the table containing the related list. In the case of a many-to-many list, this is the name of the many-to-many table, not the target table.
refField String Name of the field in the related list that refers to this CI. In the case of a many-to-many list, this is the name of the referring field in the many-to-many table, not in the target table.
Table 15. Returns
Type Description
Object Instance of the CIRelatedList for the specified list.


      
    

CIData - init()

Initializes this instance in preparation for loading a new CI.

Table 16. Parameters
Name Type Description
None
Table 17. Returns
Type Description
void

var cdta = CIData('false');
cdta.init();

CIData - loadFromCI(String cmdb_ci)

Loads the current data from a specified sys_id.

Table 18. Parameters
Name Type Description
cmdb_ci String The sys_id of the CI
Table 19. Returns
Type Description
Object The current data from the specified CI.

var cdta = CIData('false');
cdta.init();
cdta.loadFromCI('ccaf9c0a8016400b98a06818d57c7');

CIData - toString()

Converts the name of this instance to a string.

Table 20. Parameters
Name Type Description
None
Table 21. Returns
Type Description
String Name of the instance


      
    

CIData - toXML()

Returns an XML string containing a serialized version of this instance (including any related lists).

Table 22. Parameters
Name Type Description
None
Table 23. Returns
Type Description
String The XML string containing a serialized version of this instance and any related lists.

var cdta = CIData();
cdta.toXML();