--- title: CMDBQBScopedScriptableAPI - Scoped description: Provides methods to execute Configuration Management Database \(CMDB\) Query Builder operations in server-side scripts.Creates a report that shows the results of a Configuration Management Database \(CMDB\) Query Builder query and returns the URL of the report.Deletes a Configuration Management Database \(CMDB\) Query Builder query.Returns the execution details for a Configuration Management Database \(CMDB\) Query Builder query.Saves a Configuration Management Database \(CMDB\) Query Builder query and returns the sys\_id of the saved query.Updates the JSON for a Configuration Management Database \(CMDB\) Query Builder query. locale: en-US canonical_url: https://www.servicenow.com/docs/r/australia/api-reference/server-api-reference/CMDBQBScopedAPI.html release: australia product: Server API Reference classification: server-api-reference topic_type: concept last_updated: "2026-03-12" reading_time_minutes: 8 breadcrumb: [Server API reference, API reference, API implementation and reference] --- # CMDBQBScopedScriptableAPI- Scoped Provides methods to execute Configuration Management Database \(CMDB\) Query Builder operations in server-side scripts. This API is the scoped equivalent of [CMDBQueryBuilderAPI - Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/CMDBQueryBuilderAPI.md). This API requires the Configuration Management for Scoped Apps plugin \(com.snc.cmdb.scoped\) and is provided within the `sn_cmdb` namespace. For more information about CMDB Query Builder, see [CMDB Query Builder](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/servicenow-platform/cmdb-query-builder-landing-page.md). **Parent Topic:**[Server API reference](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/api-server.md) ## CMDBQBScopedScriptableAPI - 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. |
| Type | Description |
|---|---|
| Object | Details about the created report and any errors.``` { "error": "String", "message": "String", "status": "String" } ``` |
| <Object>.error | Error code. Returned when the report creation fails or invalid input parameters are provided. Possible errors: - `USER_NOT_AUTHORIZED_EXCEPTION` - `INVALID_PARAM` - `QUERY_SYS_ID_INVALID` - `REPORT_INELIGIBLE` Data type: String |
| <Object>.message |
Message containing details about the success or failure of the report creation.Possible messages:
- ` |
| <Object>.status | Status code. Returned when the update is successful.Value: `success` Data type: String |
| Name | Type | Description |
|---|---|---|
| savedQueryId | String | Sys\_id of the query to delete.This parameter can be provided as an empty string 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. |
| Type | Description |
|---|---|
| Object | Details about the deleted query and any errors.``` { "error": "String", "message": "String", "status": "String" } ``` |
| <Object>.error | Error code. Returned when the delete operation fails or invalid input parameters are provided. Possible errors: - `USER_NOT_AUTHORIZED_EXCEPTION` - `INVALID_PARAM` - `QUERY_DELETE_FAILED` Data type: String |
| <Object>.message | Message containing details about the success or failure of the delete operation.Possible messages: - `Successfully deleted the saved query` - `User is unauthorized to delete a CMDBQueryBuilder query` - `Invalid Parameters. Please provide either a valid sysId or a valid name of a saved query` - `Failed to delete the given saved query` Data type: String |
| <Object>.status | Status code. Returned when the update is successful.Value: `success` Data type: String |
| 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: - true: Execute the specified query and return its execution details. - false: Don't execute the specified query. Return the most recent execution details for the query. Default: False |
| timeout | Number | Optional. Integer value that overrides the default query execution timeout limit of five minutes.Unit: Seconds Default: Five minutes |
| Type | Description |
|---|---|
| Object | Details about the query execution and any errors.``` { "error": "String", "execution_batch_size": Number, "message": "String", "query_id": "String", "status": "String", "table_name": "String" } ``` |
| <Object>.error | Error code. Returned when the query execution fails or the specified query is not found.Possible errors: - `QUERY_EXECUTION_NOT_FOUND` - `QUERY_NOT_FOUND` - `QUERY_EXECUTION_FAILED` - `USER_NOT_AUTHORIZED_EXCEPTION` Data type: String |
| <Object>.execution\_batch\_size | Batch size of 100 allocated for the query run. This value only returns if the **executeQuery** parameter is true. See also [Batch size for CMDB Query Builder queries](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/servicenow-platform/batch-size-query.md).Data type: Number |
| <Object>.message | Message containing details about the error code. Returned when the query execution fails or the specified query is not found.Possible messages: - `Query execution details not found. Please execute the query.` - `Given saved query not found. Please make sure you are passing the name of a saved query.` - `Query execution failed. Please use a valid query.` - `User is unauthorized to execute a CMDBQueryBuilder query.` Data type: String |
| <Object>.query\_id | Sys\_id of the query execution.Data type: String Table: Query Status \[qb\_query\_status\] |
| <Object>.status | Status of the query execution.- COMPLETE: Execution is complete. - FAILED: Error occurred while executing query. - TIME\_OUT: Query execution timed out. - MAX\_LIMIT: Maximum number of return results reached. Data type: String |
| <Object>.table\_name | Name of the table that contains the query execution details.Data type: String |
| 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. |
| Type | Description |
|---|---|
| Object | Object containing details about the saved query and any errors.``` { "error": "String", "message": "String", "status": "String" } ``` |
| <Object>.error | Error code. Returned when the save operation fails or invalid input parameters are provided. Possible errors: - `USER_NOT_AUTHORIZED_EXCEPTION` - `QUERY_NAME_INVALID` - `QUERY_INVALID` - `QUERY_EXISTS_ALREADY` - `QUERY_SAVE_FAILED` Data type: String |
| <Object>.message |
Message containing details about the success or failure of the save operation. Possible messages:
- `Successfully saved the query with sysId |
| <Object>.status | Status code. Returned when the save operation is successful.Value: `success` Data type: String |
| 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. |
| Type | Description |
|---|---|
| Object | Details about the updated query and any errors.``` { "error": "String", "message": "String", "status": "String" } ``` |
| <Object>.error | Error code. Returned when the update fails or invalid input parameters are provided. Possible errors: - `USER_NOT_AUTHORIZED_EXCEPTION` - `INVALID_PARAM` - `QUERY_INVALID` - `QUERY_UPDATE_FAILED` - `UNAUTHORIZED_REPORT_SOURCE_USER` Data type: String |
| <Object>.message | Message containing details about the success or failure of the update. Possible messages: - `Successfully updated the saved query` - `User is unauthorized to update a CMDBQueryBuilder query` - `Invalid Parameters. Please provide either a valid sysId or a valid name of a saved query` - `QueryJson is invalid. Please provide a valid queryJson` - `Failed to update the given saved query` - `User is unauthorized to update report source of a saved query` Data type: String |
| <Object>.status | Status code. Returned when the update is successful.Value: `success` Data type: String |