Maintenance
Day-to-day management of templates, troubleshooting common problems, and monitoring Multi-Query performance.
Managing Templates
Templates live in the dbo.Shared_Configurations table. Each template is a row with a Code (the catalogue code) and a Value (the JSON template definition). No application restart is required after updating a template — the engine loads the template JSON per-request.
Query dbo.Shared_Configurations by Code and TenantID. The Code must exactly match the catalogue code used in the directive or REST endpoint path.
SELECT ID, Code, Value, IsActive, Deleted, LastModifiedOn
FROM dbo.Shared_Configurations
WHERE Code = 'PAYROLL_DEPT_SUMMARY'
AND TenantID = @TenantID
AND Deleted = 0;
Modify the Value column with the new template JSON. If you maintain a version field inside the JSON object (e.g., "version": 2), increment it to support change tracking and rollback.
UPDATE dbo.Shared_Configurations
SET Value = @newTemplateJson,
LastModifiedOn = GETDATE(),
LastModifiedBy = @editorUserID
WHERE Code = 'PAYROLL_DEPT_SUMMARY'
AND TenantID = @TenantID;
Always update LastModifiedOn (DATETIME) and LastModifiedBy (INT user ID) when saving changes. This supports audit trail queries and rollback identification.
Templates are resolved per-request from the database. The change takes effect immediately on the next API call or expression evaluation. Confirm by calling the execute endpoint and inspecting the response.
Disabling a Template
To temporarily block execution of a template without deleting it, set the IsActive flag to 0. The engine will return an HTTP 404 Not Found for direct API calls, and the expression directive will return an empty string.
UPDATE dbo.Shared_Configurations
SET IsActive = 0,
LastModifiedOn = GETDATE(),
LastModifiedBy = @editorUserID
WHERE Code = 'PAYROLL_DEPT_SUMMARY'
AND TenantID = @TenantID;
Re-enable the template by setting IsActive = 1. This is the preferred approach for rollbacks during incident response — it is faster than restoring JSON content.
Soft-Deleting a Template
For permanent removal, set Deleted = 1. This has the same operational effect as IsActive = 0 (callers receive 404 / empty string), but additionally signals that the record is logically deleted and should be excluded from administrative listings and exports.
UPDATE dbo.Shared_Configurations
SET Deleted = 1,
LastModifiedOn = GETDATE(),
LastModifiedBy = @editorUserID
WHERE Code = 'PAYROLL_DEPT_SUMMARY'
AND TenantID = @TenantID;
Soft-deleted records are never physically removed. This preserves the audit trail and allows recovery if a deletion was made in error.
Troubleshooting
The following accordion sections cover the most common failure modes. Expand each section for diagnostic steps.
Performance Tips
- Use
cacheSecondsin the template root for data that changes on a known schedule (e.g., payroll periods, org structures) — a value of300eliminates repeated SQL execution across concurrent users - Filter parent rows as tightly as possible — every additional parent row multiplies the number of child queries executed
- Avoid
SELECT *in all query levels — specify only the columns you need to minimize row size and network transfer overhead - Add composite indexes on FK columns used in
@parentjoin conditions, includingTenantIDas a leading column - Use
maxDepthto cap recursion depth on self-referential templates (e.g., org chart) to prevent unbounded tree walks - For HTML output, prefer the fragment variant over standalone for embedded use — it avoids the overhead of generating a full document shell
- Monitor per-template execution time in BizFirst Observe and set alerts when a template consistently exceeds an acceptable latency threshold
Monitoring
Rate limit counters, per-template execution time, SQL row counts, and error rates are emitted as BizFirst Observe metrics under the
MultiQuery.* metric namespace. Set up Grafana alerts on the MultiQuery.Execute error rate and P95 latency metrics to detect template regressions before they impact users. The templateCode label is included on all metrics, enabling per-template dashboards.