Skip to main content

Fields & Parameters

Manage query fields, input parameters, and field metadata for formatting and display.

Query Fields Overview

Query fields define:

  • Output Schema - Fields returned by the query
  • Formatting - How field values are displayed
  • Metadata - Field types, labels, and descriptions

Fields are stored in the fields property of the query and can be scanned from the payload.fields array for datasource field resolution.

GET /api/queries/{id}/fields

Get the fields defined in a query's payload with datasource field information.

Authentication: Required

Path Parameters:

ParameterTypeDescription
idstringQuery ID (UUID) or natural ID

Response:

{
"_links": {
"self": { "href": "/api/queries/{id}/fields" }
},
"_embedded": {
"inf:payload-field": [
{
"id": "date_field",
"name": "Sale Date",
"type": "field",
"fieldId": "sale_date",
"linkRef": null,
"_field": {
"id": "mysql-prod:sales:sale_date",
"datasourceId": "mysql-prod",
"schemaId": null,
"mappingId": "sales",
"fieldId": "sale_date",
"name": "sale_date",
"type": "date",
"datasource": {
"id": "mysql-prod",
"slug": "prod-mysql",
"ownerId": "admin",
"name": "Production MySQL"
}
}
},
{
"id": "amount_field",
"name": "Sale Amount",
"type": "field",
"fieldId": "amount",
"_field": {
"id": "mysql-prod:sales:amount",
"datasourceId": "mysql-prod",
"mappingId": "sales",
"fieldId": "amount",
"type": "number"
}
},
{
"id": "region_field",
"name": "Region",
"type": "field",
"fieldId": "region"
},
{
"id": "customer_field",
"name": "Customer Name",
"type": "field",
"fieldId": "customer_name",
"linkRef": "link_1",
"_field": {
"id": "mysql-prod:customers:name",
"datasourceId": "mysql-prod",
"mappingId": "customers",
"fieldId": "name",
"type": "string"
}
}
]
},
"start": 0,
"count": 4,
"total": 4
}

Field Properties:

PropertyDescription
idPayload field identifier
nameDisplay name
typeField type (typically "field")
fieldIdSource field identifier
linkRefReference to link definition (for joined fields)
_fieldResolved datasource field metadata

Resolved Field Metadata:

PropertyDescription
idFull datasource field ID (datasourceId:mappingId:fieldId)
datasourceIdSource datasource UUID
schemaIdSchema identifier (for databases with schemas)
mappingIdTable/mapping identifier
fieldIdColumn/field identifier
typeData type (string, number, date, boolean)
datasourceEmbedded datasource object
Field Resolution

The endpoint scans payload.fields and resolves each field to its datasource definition. Fields from joined tables use linkRef to determine the linked datasource and mapping.


DELETE /api/queries/{id}/fields

Remove all field definitions from a query's payload.

Authentication: Required Permission: query:write

Path Parameters:

ParameterTypeDescription
idstringQuery ID (UUID) or natural ID

Response:

Returns 204 No Content on success.

Field Removal

This removes the fields array from the query's payload, not the fields formatting object. To clear formatting, use PUT /api/queries/{id} with fields: null.


Input Parameters

Input parameters allow queries to accept dynamic values at runtime. They are defined in the inputs property of the query.

Input Definition Structure

{
"inputs": {
"startDate": {
"type": "date",
"label": "Start Date",
"description": "Beginning of date range",
"default": "2024-01-01",
"required": true,
"options": null
},
"region": {
"type": "string",
"label": "Sales Region",
"description": "Filter by region",
"default": "All",
"required": false,
"options": ["West", "East", "North", "South", "All"]
},
"minAmount": {
"type": "number",
"label": "Minimum Amount",
"default": 0,
"required": false
}
}
}

Input Properties:

PropertyTypeDescription
typestringInput type: string, number, date, boolean, datetime
labelstringDisplay label for UI
descriptionstringHelp text
defaultanyDefault value
requiredbooleanWhether input is required
optionsarrayList of allowed values (for dropdowns)

Parameter Usage in Queries

Parameters are referenced in query payloads using language-specific syntax:

SQL:

{
"language": "sql",
"payload": {
"sql": "SELECT * FROM sales WHERE date >= :startDate AND region = :region"
},
"inputs": {
"startDate": { "type": "date", "label": "Start Date" },
"region": { "type": "string", "label": "Region" }
}
}

i5-QL:

{
"language": "i5-ql",
"payload": {
"filters": [
{ "field": "date", "operator": ">=", "value": { "param": "startDate" } }
]
},
"inputs": {
"startDate": { "type": "date", "label": "Start Date" }
}
}

GET /api/queries/{id}/input-templates

Get input parameter templates for a query based on its language.

Authentication: Required

Path Parameters:

ParameterTypeDescription
idstringQuery ID (UUID) or natural ID

Response:

Returns language-specific input templates and suggestions.

{
"suggested": [
{
"name": "startDate",
"type": "date",
"label": "Start Date",
"description": "Beginning of date range"
},
{
"name": "endDate",
"type": "date",
"label": "End Date",
"description": "End of date range"
}
],
"common": [
{
"name": "limit",
"type": "number",
"label": "Row Limit",
"default": 1000
},
{
"name": "offset",
"type": "number",
"label": "Offset",
"default": 0
}
]
}
Template Discovery

Use this endpoint to discover recommended parameter names and types for a query language. The suggestions are based on common patterns and query analysis.


Field Formatting

The fields property (separate from payload.fields) stores formatting metadata for display:

{
"fields": {
"sale_date": {
"format": "MM/DD/YYYY",
"label": "Sale Date",
"align": "left"
},
"amount": {
"format": "$0,0.00",
"label": "Amount",
"align": "right",
"color": {
"rules": [
{
"condition": { "operator": "<", "value": 0 },
"color": "#ff0000"
},
{
"condition": { "operator": ">", "value": 1000 },
"color": "#00ff00"
}
]
}
},
"region": {
"format": "uppercase",
"label": "Region"
}
}
}

Format Options:

Field TypeFormat Examples
DateMM/DD/YYYY, YYYY-MM-DD, DD-MMM-YY
Number0,0.00, $0,0.00, 0.00%, 0a (abbreviated)
Stringuppercase, lowercase, capitalize
BooleanYes/No, True/False, 1/0

Formatting Properties:

PropertyTypeDescription
formatstringFormat string (type-specific)
labelstringDisplay label
alignstringAlignment: left, center, right
colorobjectConditional coloring rules
widthintegerColumn width (pixels)
hiddenbooleanHide field in default view

Updating Field Formatting

Use PUT /api/queries/{id} to update field formatting:

{
"fields": {
"sale_date": {
"format": "YYYY-MM-DD",
"label": "Date"
},
"amount": {
"format": "$0,0.00",
"color": {
"rules": [
{ "condition": { "operator": "<", "value": 0 }, "color": "red" }
]
}
}
}
}

Field Settings

The settings property can store field-specific configuration:

{
"settings": {
"fieldDefaults": {
"dateFormat": "MM/DD/YYYY",
"numberFormat": "0,0.00"
},
"fieldOrder": ["date", "region", "amount", "customer"],
"hiddenFields": ["internal_id", "created_at"],
"timeout": 60000
}
}

Common Settings:

SettingTypeDescription
fieldDefaultsobjectDefault formats for field types
fieldOrderarrayDefault field display order
hiddenFieldsarrayFields to hide by default
timeoutintegerQuery execution timeout (ms)

GET /api/queries/{id}/settings

Get query-specific settings including field defaults.

Authentication: Required

Path Parameters:

ParameterTypeDescription
idstringQuery ID (UUID) or natural ID

Response:

Returns the query's settings object merged with user-specific settings.

{
"fieldDefaults": {
"dateFormat": "MM/DD/YYYY"
},
"timeout": 60000,
"userSettings": {
"params": {
"startDate": "2024-01-01"
}
}
}

PUT /api/queries/{id}/settings

Update query settings.

Authentication: Required Permission: query:write

Path Parameters:

ParameterTypeDescription
idstringQuery ID (UUID) or natural ID

Request Body:

{
"fieldDefaults": {
"dateFormat": "YYYY-MM-DD",
"numberFormat": "$0,0.00"
},
"timeout": 120000,
"fieldOrder": ["date", "amount", "region"]
}

Response:

Returns the updated settings object.

Settings vs Fields
  • Use settings for query-level configuration and defaults
  • Use fields for field-specific formatting and display rules
  • Settings apply to all instances; field formatting is per-field

POST /api/queries/{id}/settings/_restore

Restore query settings to defaults.

Authentication: Required Permission: query:write

Path Parameters:

ParameterTypeDescription
idstringQuery ID (UUID) or natural ID

Response:

Returns the restored default settings.

{
"fieldDefaults": {},
"timeout": 60000
}
Reset Scope

This only resets the query's settings object. Field formatting (fields) and user-specific settings are not affected.


Best Practices

Input Parameters

  1. Use Descriptive Names - startDate not sd, customerRegion not reg
  2. Provide Defaults - Always set sensible default values
  3. Add Descriptions - Help users understand parameter purpose
  4. Use Options - Provide dropdown options when values are constrained
  5. Mark Required - Clearly indicate which parameters are mandatory

Field Formatting

  1. Consistent Formats - Use the same date/number formats across related queries
  2. Conditional Coloring - Highlight important values (negative amounts, overdue dates)
  3. Appropriate Alignment - Numbers right-aligned, text left-aligned
  4. Hide Noise - Hide technical fields users don't need to see
  5. Label Everything - Use friendly labels instead of field names

Performance

  1. Limit Field Resolution - Only resolve fields when needed
  2. Cache Format Strings - Reuse format strings across fields
  3. Avoid Heavy Computation - Don't compute formatting in query payload
  4. Use Field Defaults - Set defaults in settings rather than per-field