Skip to main content

System Queries

This chapter describes how to update System Queries. For an overview of System Queries and their use cases, see System Queries.

Update a System Query

Use the systemQuerys.update mutation to update an existing System Query:

mutation updateQuery($entities: [SystemQueryInputUpdate]!) {
runtime {
systemQuerys {
update(entities: $entities) {
rtId
ckTypeId
name
queryCkTypeId
columns
sorting {
attributePath
sortOrder
}
fieldFilter {
attributePath
operator
comparisonValue
}
attributeSearchFilter {
attributePaths
searchValue
}
textSearchFilter {
searchValue
}
}
}
}
}

Update name and columns

Update the display name and add new columns:

{
"entities": [
{
"rtId": "693c66ce464d7d9e1396cf1f",
"name": "Active Energy Meters (Extended)",
"columns": ["name", "voltage", "ampere", "power", "state", "description"]
}
]
}

Update filters

Change the filter criteria:

{
"entities": [
{
"rtId": "693c66ce464d7d9e1396cf1f",
"fieldFilter": [
{ "attributePath": "state", "operator": "EQUALS", "comparisonValue": "OFF" },
{ "attributePath": "voltage", "operator": "GREATER_THAN", "comparisonValue": 220 }
]
}
]
}

Update sorting

Change the sort order:

{
"entities": [
{
"rtId": "693c66ce464d7d9e1396cf1f",
"sorting": [
{ "attributePath": "voltage", "sortOrder": "DESCENDING" },
{ "attributePath": "name", "sortOrder": "ASCENDING" }
]
}
]
}

Update search filter

Modify the attribute search configuration:

{
"entities": [
{
"rtId": "693c66ce464d7d9e1396cf1f",
"attributeSearchFilter": {
"attributePaths": ["name", "description", "serialNumber"],
"searchValue": ""
}
}
]
}

Input fields

FieldTypeRequiredDescription
rtIdOctoObjectIdYesThe ID of the System Query to update
nameStringNoNew display name
queryCkTypeIdStringNoNew entity type to query
columns[String]NoNew list of column paths
sorting[SortInput]NoNew sort configuration
fieldFilter[FieldFilterInput]NoNew filter configuration
attributeSearchFilterAttributeSearchFilterInputNoNew wildcard search configuration
textSearchFilterTextSearchFilterInputNoNew full-text search configuration

Only fields that are provided will be updated. Fields not included in the update request remain unchanged.

Response

The mutation returns the updated System Query:

{
"data": {
"runtime": {
"systemQuerys": {
"update": [
{
"rtId": "693c66ce464d7d9e1396cf1f",
"ckTypeId": "System/Query",
"name": "Active Energy Meters (Extended)",
"queryCkTypeId": "Industry.Energy/EnergyMeter",
"columns": ["name", "voltage", "ampere", "power", "state", "description"],
"sorting": [
{ "attributePath": "voltage", "sortOrder": "DESCENDING" },
{ "attributePath": "name", "sortOrder": "ASCENDING" }
]
}
]
}
}
}
}

Update data via System Query

System Queries can also be used to update the entities returned by the query. This is useful when you want to modify data in a tabular format (e.g., from Excel or a data grid).

mutation updateQueryData($queryRtId: OctoObjectId!, $entities: [RtQueryRowUpdate!]!) {
runtime {
runtimeQuery(rtId: $queryRtId) {
update(entities: $entities) {
rtId
ckTypeId
rtWellKnownName
rtVersion
cells {
items {
attributePath
value
}
}
}
}
}
}

Variables:

{
"queryRtId": "693c66ce464d7d9e1396cf1f",
"entities": [
{
"rtId": "693c51af464d7d9e1396cf12",
"cells": [
{ "attributePath": "contact.firstName", "value": "Janet" },
{ "attributePath": "contact.address.street", "value": "New Street 123" }
]
}
]
}

RtQueryRowUpdate structure

FieldTypeDescription
rtIdOctoObjectIdThe ID of the entity to update
cells[RtQueryCellUpdate!]List of cells (attribute path and value) to update

Response

The mutation returns the updated rows with their current cell values:

{
"data": {
"runtime": {
"runtimeQuery": {
"update": [
{
"rtId": "693c51af464d7d9e1396cf12",
"ckTypeId": "EnergyCommunity/Customer",
"rtWellKnownName": null,
"rtVersion": 2,
"cells": {
"items": [
{ "attributePath": "contact.firstName", "value": "Janet" },
{ "attributePath": "contact.address.street", "value": "New Street 123" },
{ "attributePath": "contact.address.cityTown", "value": "Berlin" }
]
}
}
]
}
}
}
}

This approach allows tools like Office Add-ins to read data via a System Query, let users edit it in a spreadsheet, and write back changes using the same query definition.