Portal Community

The Directive

The Multi-Query expression directive is a single token that the BizFirst expression engine recognizes and resolves at evaluation time. The engine finds the template by its catalogue code, injects the TenantID from context, resolves any additional parameters from the EvaluationContext, executes the nested SQL tree, and returns the output inline.

Basic form (JSON output)

{{multi-query:sqlserver.TEMPLATE_CODE}}

JSON output — explicit

{{multi-query:sqlserver.TEMPLATE_CODE|outputFormat=json}}

HTML fragment (embeds inside existing page)

{{multi-query:sqlserver.TEMPLATE_CODE|outputFormat=html|outputFormatTemplate=fragment}}

HTML standalone (complete self-contained document)

{{multi-query:sqlserver.TEMPLATE_CODE|outputFormat=html|outputFormatTemplate=standalone}}

Pipe-delimited options in the directive override the defaults stored in the template's options block, allowing a single template to serve both JSON consumers (APIs, workflow logic) and HTML consumers (reports, emails) without duplication.

Where Expressions Are Used

The directive works anywhere the BizFirst expression engine evaluates a string. This covers the entire platform surface:

Workflow Node Outputs

FlowEngine nodes can produce Multi-Query output as their payload — passing a nested JSON tree downstream to the next node, or emitting an HTML report as a node artifact.

Atlas Form Display Fields

Read-only form fields configured with an expression source render live hierarchical data directly inside a form — no custom API call required from the form layer.

AppStudio Widget Bindings

AppStudio widgets that accept expression bindings can display Multi-Query results as structured tables or JSON grids, refreshed on each form load or on a configurable interval.

Email / SMS Templates

Notification templates can embed a standalone HTML table (e.g., a payroll summary or approval summary) directly in the message body using the outputFormatTemplate=standalone option.

API Response Transforms

BizFirst API response transformation pipelines can include Multi-Query directives to enrich outbound payloads with real-time nested data before the response is delivered to the caller.

Example: Payroll Report in an Email

A workflow node generates a department payroll report and attaches it as the body of an outbound email notification. The email template references the Multi-Query directive with the HTML standalone format so the email client receives a fully styled, self-contained table with no external dependencies.

{
  "nodeType": "SendEmail",
  "to": "{{context.ManagerEmail}}",
  "subject": "Payroll Report — {{context.DepartmentName}} — {{context.PeriodLabel}}",
  "body": "{{multi-query:sqlserver.PAYROLL_REPORT_DEPT|outputFormat=html|outputFormatTemplate=standalone}}",
  "isBodyHtml": true
}

When the workflow engine evaluates the body field, it resolves the directive using the current EvaluationContext, which must contain DepartmentID and any other parameters declared in the PAYROLL_REPORT_DEPT template. The result — a complete HTML payroll table — replaces the directive token in the outgoing email.

Passing Parameters via EvaluationContext

Template parameters (other than TenantID) are resolved from the EvaluationContext at directive evaluation time. The EvaluationContext is the runtime key-value bag that the FlowEngine, Atlas, or AppStudio host populates before invoking the expression engine.

For the directive to find its parameters, the name values in the template's parameters array must match keys present in the EvaluationContext (case-insensitive).

// Template parameters declaration (inside the stored QueryTemplate JSON)
"parameters": [
  { "name": "DepartmentID", "type": "int",      "defaultValue": null },
  { "name": "PeriodStart",  "type": "datetime", "defaultValue": null },
  { "name": "PeriodEnd",    "type": "datetime", "defaultValue": null }
]

// EvaluationContext provided by the workflow node at runtime
{
  "DepartmentID": 14,
  "PeriodStart":  "2025-11-01",
  "PeriodEnd":    "2025-11-30",
  "ManagerEmail": "sarah.thompson@acme.com",
  "DepartmentName": "Engineering",
  "PeriodLabel":  "November 2025"
}

The expression engine extracts DepartmentID, PeriodStart, and PeriodEnd from the context and passes them as SQL parameters. The remaining context keys (ManagerEmail, etc.) are used by other tokens in the same template string and are ignored by the Multi-Query resolver.

TenantID Is Automatic

The TenantID is resolved from the EvaluationContext automatically — it is set by the platform from the active session or JWT before any expression is evaluated. You must never declare TenantID as a template parameter or pass it manually from a workflow node. Doing so has no effect; the platform value always takes precedence.

Missing Parameters

If a required template parameter is missing from the EvaluationContext at directive evaluation time, the directive returns an empty string and logs a warning to the platform diagnostics log — it does not throw an exception or halt the workflow. This silent-fail behavior means missing parameters can produce blank fields or empty report sections. Always validate that all required parameters are populated in context before the expression node executes.