CMDBQueryBuilderAPI - Global
-
- UpdatedJan 30, 2025
- 6 minutes to read
- Yokohama
- API reference
Provides methods to execute Configuration Management Database (CMDB) Query Builder operations in server-side scripts.
This API requires the Configuration Management Database (CMDB) application (com.snc.cmdb).
To use these methods in a scoped application, see CMDBQBScopedScriptableAPI - Scoped.
For more information about CMDB Query Builder, see CMDB Query Builder.
CMDBQueryBuilderAPI - createReport(String savedQueryId, String savedQueryName)
Creates a report that shows the results of a Configuration Management Database (CMDB) Query Builder query and returns the URL of the report.
Name | Type | Description |
---|---|---|
savedQueryId | String | Sys_id of the query to use for the report. This parameter is not required if a query name is provided. Table: Saved Queries [qb_saved_query] |
savedQueryName | String | Name of the query to use for the report. This parameter is not required if a query sys_id is provided. Table: Saved in the Name field of the Saved Queries [qb_saved_query] table. |
Example
This example shows how to create a report by passing a saved query name.
Output:
Example
This example shows an error when the provided query name is invalid.
Output:
CMDBQueryBuilderAPI - deleteQuery(String savedQueryId, String savedQueryName)
Deletes a Configuration Management Database (CMDB) Query Builder query.
Name | Type | Description |
---|---|---|
savedQueryId | String | Sys_id of the query to delete. This parameter is not required if a query name is provided. Table: Saved Queries [qb_saved_query] |
savedQueryName | String | Name of the query to delete. This parameter is not required if a query sys_id is provided. Table: Saved in the Name field of the Saved Queries [qb_saved_query] table. |
Example
This example shows how to delete a saved query by passing the query name.
Output:
CMDBQueryBuilderAPI - getSavedQueryExecutionDetails(String savedQueryName, Boolean executeQuery, Number timeout)
Returns the execution details for a Configuration Management Database (CMDB) Query Builder query.
Optionally, you can execute the query in order to return current execution details.
If a timeout or memory issue occurs while executing the query, you can fine tune the query batch size to help alleviate these problems. For more information, see Batch size for Query Builder saved queries.
Name | Type | Description |
---|---|---|
savedQueryName | String | Name of the query to retrieve execution details for. Table: Name field in the Saved Queries [qb_saved_query] table. |
executeQuery | Boolean | Optional. Flag that indicates whether to execute the specified query. Valid values:
Default: False |
timeout | Number | Optional. Integer value that overrides the default query execution timeout limit of five minutes. Unit: Seconds Default: Five minutes |
Example
This example shows how to execute a saved query and set the query execution timeout value to 10 minutes.
Output:
CMDBQueryBuilderAPI - saveQuery(String savedQueryName, String queryJson)
Saves a Configuration Management Database (CMDB) Query Builder query and returns the sys_id of the saved query.
Name | Type | Description |
---|---|---|
savedQueryName | String | Name to save the query under. Table: Saved in the Name field of the Saved Queries [qb_saved_query] table. |
queryJson | String | JSON that defines the query. Table: Saved in the Query field of the Saved Queries [qb_saved_query] table. |
Example
This example shows how to add a query to the Saved Queries [qb_saved_query] table.
Output:
Example
This example shows an error when an invalid JSON query is provided.
Output:
CMDBQueryBuilderAPI - updateQuery(String savedQueryId, String savedQueryName, String queryJson)
Updates the JSON for a Configuration Management Database (CMDB) Query Builder query.
Name | Type | Description |
---|---|---|
savedQueryId | String | Sys_id of the query to update. This parameter is not required if a query name is provided. Table: Saved Queries [qb_saved_query] |
savedQueryName | String | Name of the query to update. This parameter is not required if a query sys_id is provided. Table: Saved in the Name field in the Saved Queries [qb_saved_query] table. |
queryJson | String | JSON to update the query with. Table: Saved in the Query field in the Saved Queries [qb_saved_query] table. |
Example
This example shows how to update a saved query by passing the query name.
Output:
Example
This example shows an error when the query sys_id and name are both missing from the method call.
Output:
On this page
- CMDBQueryBuilderAPI - createReport(String savedQueryId, String savedQueryName)
- CMDBQueryBuilderAPI - deleteQuery(String savedQueryId, String savedQueryName)
- CMDBQueryBuilderAPI - getSavedQueryExecutionDetails(String savedQueryName, Boolean
executeQuery, Number timeout)
- CMDBQueryBuilderAPI - saveQuery(String savedQueryName, String queryJson)
- CMDBQueryBuilderAPI - updateQuery(String savedQueryId, String savedQueryName, String queryJson)