Skip to content

This page is for integrators and developers who create, run or export reports through the API, or need to know exactly how a rendition is produced. It documents the report model, the validation rules and error codes, the endpoints, the export pipeline and scheduled delivery.

A report is a saved, tabular projection over a data entity. It binds a data query (the row source) to an ordered list of fields (the columns), plus presentation, scheduling, notification, and access options. Once defined, a report can be executed to return live rows, counted, and exported to PDF or XLSX renditions.

  • Web-only. Reports are available in the web application only. A report link opens only on the web; on mobile it resolves to a NotSupportedLink and cannot be navigated to.

A report is stored as a DataEntry of the core Report entity. The concrete model is ReportEntry, whose value holds a ReportEntryValue:

ReportEntry (extends DataEntry)
value: ReportEntryValue

ReportEntry’s constructor force-assigns dataEntity = REPORT_ENTITY_ID, so every report row is tagged to the Report core entity regardless of the payload.

From report-entry-value.model.ts:

FieldTypeRequiredNotes
nameLocalizedValueyesReport display name (per-language). Must be unique per related data entity — see validation.
normalizedNamestringnoAuto-generated programmatic identifier derived from name; unique per related DataEntity.
descriptionNullableLocalizedValuenoLocalized description; used in the PDF header text.
iconIcon(require: true)Report icon.
dataSourceDataEntrySource(require: true)The row source. Only the Query type is supported (see below).
fieldsstring[](require: true, minItems: 1)Ordered list of entity field paths to project as columns. Order is preserved.
allowChangeFieldsbooleannoIf true, export callers may narrow the exported columns via selectedColumns.
relatedToDataEntityReferenceProperty(require: true)The entity the report runs against ({dataEntity, dataEntry}).
authenticatedAuthenticatedViewOptionnoAccess/authentication config. Defaults to {isRestricted: false, enabled: true}.
isPublishedbooleannoDefault false. Publishing gates the permission requirement and schedule validation.
scheduleReportScheduleModelnoOptional scheduled delivery timer.
inAppNotificationSendReportNotificationActionOptionsnoIn-app notification delivery config.
emailNotificationSendReportEmailActionOptionsnoEmail delivery config.
displayOrdernumbernoDefault 0. Ordering hint.
designReportDesignOptionsnoPDF layout / header / footer options.
domainReferencePropertynoOptional domain reference.
sharingApplicationSharingyesApplication-sharing metadata.
helpReportHelpnoContextual help text. Since 1.2

Note on require vs required. Several properties in the model use the misspelled decorator key require: true (e.g. icon, dataSource, fields, relatedTo). LoopBack’s property validation reads required (not require), so these are not enforced as required by the framework schema — the business rules in ReportService (below) are what actually enforce dataSource type, fields content, and relatedTo.

dataSource is a DataEntrySource:

FieldTypeNotes
typeDataCollectionTypeEnumMust be Query (enum value 2). Store and Collection are rejected.
storestringStore name (pattern-constrained).
collectionUUIDCollection id.
queryUUIDThe data query id that produces the rows.

DataCollectionTypeEnum = { Store = 0, Collection = 1, Query = 2 }. Report validation requires type === Query, so every report resolves its rows through a data query.

The report-reference-property.model.ts constrains a report reference to always point at the DataEntity core entity (dataEntity is a JSON-schema const of CoreEntities.DataEntity) with a dataEntry UUID. ReportEntryValue.relatedTo is typed as the more general DataEntityReferenceProperty, but the same {dataEntity, dataEntry} shape applies.

authenticated is an AuthenticatedViewOption:

FieldTypeNotes
enabledbooleanWhether authenticated access is enabled (schema default false).
defaultViewbooleanWhether this is the default view (schema default false).
isRestrictedbooleanWhether the report has explicit permissions attached. Calculated only — it is not accepted from create/update payloads directly for this purpose; it drives the publish permission check.

The designer’s Report Design choices map to ReportDesignOptions, whose defaults are pageHeader = true, organizationHeader = true, pageFooter = true, organizationFooter = false.

Permissions are not stored on the report document; they live in access-rights (see Internals and invariants). Publishing a restricted report with no permissions selected is rejected.

All create/update paths run through ReportService.validateReportValue and validateNameUniqueness.

validateReportValue(value)

  1. value.dataSource.type must be DataCollectionTypeEnum.Query, else ReportDataSourceSupportedException (error REPORT_DATA_SOURCE_NOT_SUPPORTED).
  2. When relatedTo.dataEntity === CoreEntities.DataEntity:
    • The query (dataSource.query) must exist, else DataQueryNotFound.
    • The related entity (relatedTo.dataEntry) must exist, else EntryNotExistException.
    • The entity must not be archived, else EntityArchivedException.
    • The query’s dataEntity must equal relatedTo.dataEntry, else DataQueryNotBelongToEntity.
    • Field validation (validateReportFields): fields must be non-empty (ReportFieldsLengthException, REPORT_FIELDS_LENGTH) and every entry must exist in the entity’s getAllFieldsPaths() — unknown fields raise ReportFieldsNotExistException (REPORT_FIELDS_NOT_EXIST), listing the offending paths.
  3. If the report isPublished and has a schedule.enabled one-time send whose oneTime timestamp is in the past, ReportSendingTimeCanNotBeInThePastException (REPORT_SENDING_TIME).

validateNameUniqueness(report, selfId?) — for each configured language, if name[lang] is set, the service looks for an existing report with the same value.relatedTo.dataEntry and the same value.name.<lang>. On PATCH, selfId excludes the current report (id neq selfId). A collision raises ReportExistException (REPORT_EXISTS). Uniqueness is therefore scoped per related data entity, per language.

All routes are on ReportEntryController, authenticated with the OSOS OAuth2 strategy and authorized per-route. id is the report entry id.

MethodPathPurpose
POST/v1/reportsCreate a report.
GET/v1/reportsList reports (LoopBack filter).
GET/v1/reports/countCount reports (LoopBack where).
GET/v1/reports/{id}Get one report (joins permissions).
PATCH/v1/reports/{id}Update a report.
PATCH/v1/reports/{id}/permissionsUpdate only the report’s access/permissions.
DELETE/v1/reports/{id}Delete a report.
GET/v1/reports/{id}/entriesExecute the report to rows (v1 filter).
GET/v2/reports/{id}/entriesExecute the report to rows (criteria + search).
GET/v1/reports/{id}/entries/countRow count (v1 where).
GET/v2/reports/{id}/entries/countRow count (criteria + search).
GET/v2/reports/{id}/export/{format}Export rows to a file (pdf or xlsx).

Create (POST /v1/reports) — body is a ReportEntryDto without id (a NewReportEntry): the ReportEntryValue plus optional permissions: Permission[]. The flow runs validateNameUniqueness then validateReportValue, strips permissions, sends a CreateDataEntryCommand on the service bus (async, CQRS-style) for the Report entity, awaits invokerService.registerToken(messageId) to get the created result, then stores permissions separately in access-rights. The row is created by the command handler, not inline.

Read (GET /v1/reports/{id}) — returns the stored report plus a permissions array joined at read time from access-rights (convertAccessRightToPermissions(Report, id)); permissions are not stored on the report document.

Update (PATCH /v1/reports/{id}) — body is a partial ReportEntryDto. After validation, a publish permission guard applies: if value.isPublished and authenticated.enabled and authenticated.isRestricted and the supplied permissions are empty and no permissions already exist, it throws ReportPermissionsNotSelectedException (HTTP 422, REPORT_PERMISSION_NOT_SELECTED). The report is then persisted via updateById; access-rights are reconciled before publishing (order matters — dependency-sync re-fetches via GET /v1/reports/{id}): if isRestricted === false, stored permissions are cleared; otherwise a non-empty supplied set is stored. Finally a DataEntryUpdatedEvent is published, carrying a changed-field marker for isPublished when it changed.

Update permissions (PATCH /v1/reports/{id}/permissions) — authorized by systemAdminVoterFactory() (system-admin only). Body is an UpdateResourcePermissionsDto (permissions + authenticated). It applies the same publish guard, writes the new authenticated block, publishes a DataEntryUpdatedEvent, then reconciles access-rights.

Delete (DELETE /v1/reports/{id}) — sends a DeleteDataEntryCommand on the bus, awaits its token, then publishes a ReportDeletedEvent. Deletion is command-driven like creation.

v1 (/v1/reports/{id}/entries, /v1/reports/{id}/entries/count) accept a LoopBack filter/where. The controller resolves the related entity from report.value.relatedTo.dataEntry, then forces state = Active, virtual != true (unless include_virtual=true), and dataEntity = <entity id>, and calls dataSourceService.find(entity, report.value.fields, filter, count?, report.value.dataSource).

v2 (/v2/reports/{id}/entries, /v2/reports/{id}/entries/count) accept a structured filterCriteria/whereCriteria (a FilterExpression tree) plus a free-text search param. The controller builds an AND expression that always pins state = Active (and virtual != true unless include_virtual), optionally AND-ed with the caller’s criteria, and delegates to dataSourceService.findV2 / countV2. The entries endpoint passes revealSensitiveFields = true.

Common query params:

ParamTypeMeaning
include_virtualbooleanInclude rows flagged virtual (default excludes them).
searchstring (v2)Free-text search across the projected fields.
filterCriteria / whereCriteriaobject (v2)Structured filter expression.

End users start an export from the report’s actions menu in the web application — Export to Excel or Export to PDF. Both options call the export endpoint below.

GET /v2/reports/{id}/export/{format} — format is an ExportFormatEnum: pdf or xlsx (there is no CSV export). Query params: filterCriteria, search, include_virtual, and selectedColumns (a string array). The response is a file download — content type and Content-Disposition: attachment; filename=... come from the exporter result. The declared content types are application/vnd.openxmlformats-officedocument.spreadsheetml.sheet (XLSX) and application/pdf. Since 1.2 the export URL carries {format} as a path segment.

The report route’s format is typed ExportFormatEnum (pdf | xlsx), the declared content types are XLSX and PDF only, and the XLSX and PDF exporters are the only two registered. The CSV that 1.10 introduced belongs to the quick export of a gallery and its admin twin on the entity page — GET /v3/entities/{entity}/views/{id}/entries/export and GET /v3/entities/{entity}/entries/export, both format=xlsx|csv — documented in Data Views & Faces. Nothing in that change reaches reports, which remain XLSX / PDF and web-only (the mobile app has no reports).

ReportService.exportReportV2 loads the report, derives the file name from the localized report name in the caller’s language, builds the same state = Active (+ optional virtual != true) AND filter as v2 execute (AND-ed with any filterCriteria), selects columns, fetches rows via dataSourceService.findV2(..., revealSensitiveFields = true), and calls ExportService.export.

By default the exported columns are report.value.fields. If selectedColumns is provided and non-empty and report.value.allowChangeFields is true, the exported columns become selectedColumns intersected with the report’s own fields (a report can never export a column it does not define). If allowChangeFields is false, selectedColumns is ignored. Since 1.2 (selectedColumns + allowChangeFields).

ExportService.export resolves the concrete exporter through ExporterFactoryService (an unknown format yields InvalidExportFormatException). Before handing rows over, convertDataEntryToExportableData flattens each DataEntry.value into display-ready strings per field type:

Field kindExport rendering
ADT string / date / datetime / timeResolved collection value; dates dd/MM/yyyy, datetime dd/MM/yyyy hh:mm, time hh:mm (user timezone or UTC).
Reference / User_resolved.mainTitle (localized).
Localized textLocalized value for the user’s language.
DateTimedd/MM/yyyy hh:mm.
Datedd/MM/yyyy.
Date / DateTime rangeTwo endpoints joined by -.
Timehh:mm.
Month-YearMM/yyyy.
Category_resolved.label (localized).
Blob / fileFile name.
MapJSON.stringify(geometry.coordinates).
Switch_resolved.mainTitle (localized).
PasswordMasked as ****.
Other (icon, phone, …)Raw value.

Repeatable / multi-value fields render each element with the same rule and join with , (ranges join their two dates with -). Report execution and export share this converter, so exported values match what the entries endpoint returns.

Sensitive fields. Execution and export request sensitive-field values (revealSensitiveFields = true), but each sensitive field is still masked (****) for anyone without sensitive-field access to it, and password-typed fields are always masked. Masking applies identically to the exported file, the on-screen report, and the emailed attachment.

ExportExcel (format xlsx, ExcelJS) builds one worksheet named after the report/entity:

  • Columns come from the entity’s fields filtered to the report’s field set (getAllFields(true)), each 20 units wide, header = localized field name.
  • Block fields produce a merged sub-header row spanning their child columns. Repeatable blocks expand horizontally — each block instance repeats the child columns (<field>.<index>), sized to the maximum instance count across the exported rows.
  • If a default organization header image exists, it is placed in a merged A1:D1 banner and the data starts on row 2.
  • Header cells are bold, centered, thin-bordered; sub-header cells bold with a bottom border.
  • Returns { fileName: "<name>.xlsx", file: <ArrayBuffer>, mimeType: spreadsheetml.sheet }.

XLSX has no column cap.

ExportPdf (format pdf) uses the @osos/fluentreports engine:

  • Column cap. At most MAX_COLUMNS_COUNT (default 7) columns are rendered; fields beyond the 7th are dropped (rptFields.slice(0, 7)). This is a hard PDF-only limit.
  • Column header labels use the localized field name (columns are internally keyed <normalizedName>#<localizedName>; block fields render block.field).
  • Layout follows design.layout (ReportLayoutEnum: Portrait = 0, Landscape = 1) — landscape when layout === Landscape.
  • Header/footer sections are driven by ReportDesignOptions: organizationHeader / organizationFooter pull the default organization’s organization_header / organization_footer images; pageHeader prints the report name/description text (default true); pageFooter prints Page {0} of {1} / صفحة {0} من {1} page numbers (default true, and printed even when there is no design); reportHeader / reportFooter carry a ReportHeaderFooterValue whose type is Text (0) or Image (1).
  • RTL/Arabic support uses right-aligned images and the Tajawal font (registered from FONTS_PUBLIC_DIR, default public/fonts).
  • Section text is truncated to SECTION_MAX_CHAR_COUNT (default 171) across SECTION_MAX_LINE_COUNT (default 3) lines.
  • On any render error, the exporter logs and throws DataExportException.
  • Returns { file: <Buffer>, fileName: "<name>.pdf", mimeType: "application/pdf" }.

The PDFExporterOptions handed to the exporter set pdfDesign = report.design and pdfHeaderText = "<report name> \n <description>", plus an empty pdfDesignConfigs — so the exporter falls back to its built-in defaults.

A report may carry delivery configuration; these are stored on the report but executed by other subsystems (timer/notification services), not by the endpoints above.

  • schedule (ReportScheduleModel extends TimerOptionsEventConfig): enabled: boolean, plus oneTime?: string and repeat? (a DataEntityTriggerRepeat with a cron/human-readable expression and optional timezone/startDate/endDate). A published report with an enabled one-time schedule in the past is rejected at save time (see validation).
  • emailNotification (SendReportEmailActionOptions): to/cc/bcc recipient lists, a template (UUID or inline EmailTemplateValue), a tokensMap, optional link, attachment/attachments, and an optional from config.
  • inAppNotification (SendReportNotificationActionOptions): channels, recipients, optional module/notificationType, a template (UUID or inline NotificationTemplateValue), and a tokensMap.

Scheduled delivery and the attachment — correction Since 1.8

Section titled “Scheduled delivery and the attachment — correction Since 1.8”

When a scheduled report’s timer job fires, data-service’s ScheduledReportJobTriggeredHandler loads the report and sends the configured email only when it is both isPublished and schedule.enabled. emailNotification.attachment.enabled and emailNotification.link.enabled are independent toggles — a common configuration is link-only, with the attachment turned off.

Before this fix, the handler unconditionally read the attachment upload’s result even when attachment.enabled was false, so the read threw and the email was silently skipped — the surrounding try/catch rethrew into the message-bus consumer with no user-facing surface, and the bus retried and then gave up. Exporting/uploading the attachment is now best-effort: it runs inside its own try/catch, and a storage outage, a render failure, or a disabled attachment all degrade to sending the email without an attachment instead of dropping the notification. The failure is still logged as a structured warning ({reportId, err}) so an attachment failure stays diagnosable per report.

ExceptionCodeHTTPCause
ReportDataSourceSupportedExceptionREPORT_DATA_SOURCE_NOT_SUPPORTED4xx (validation)dataSource.type is not Query.
ReportFieldsLengthExceptionREPORT_FIELDS_LENGTH4xx (validation)Empty fields.
ReportFieldsNotExistExceptionREPORT_FIELDS_NOT_EXIST4xx (validation)One or more fields are not on the entity.
ReportSendingTimeCanNotBeInThePastExceptionREPORT_SENDING_TIME4xx (validation)Published report scheduled for a past one-time send.
ReportExistExceptionREPORT_EXISTS4xx (validation)Name collides with another report on the same entity/language.
ReportPermissionsNotSelectedExceptionREPORT_PERMISSION_NOT_SELECTED422Publishing a restricted report with no permissions selected.
DataQueryNotFound—4xxdataSource.query does not exist.
DataQueryNotBelongToEntity—4xxQuery’s entity ≠ relatedTo.dataEntry.
EntryNotExistException—4xxrelatedTo.dataEntry entity missing.
EntityArchivedException—4xxRelated entity is archived.
InvalidExportFormatException—4xxExport format has no bound exporter.
DataExportException—5xxXLSX/PDF render failure.
  • Only Query sources. Report execution always resolves rows through a data query; store/collection sources are rejected. ReportDataSourceSupportedException is the single guard.
  • Fields are the column contract. fields (order-significant) drive both execution projection and export columns. PDF silently truncates to 7 columns; XLSX has no such cap.
  • Permissions live in access-rights, not on the doc. Read joins them in; write reconciles them separately and deliberately before publishing so the dependency-sync re-fetch sees the new set.
  • CQRS for create/delete. Create and delete go through service-bus commands (CreateDataEntryCommand / DeleteDataEntryCommand) and await an invoker token; update writes the repository directly and emits a DataEntryUpdatedEvent.
  • Sensitive fields revealed on execute/export, then masked per access. v2 execute and export pass revealSensitiveFields = true; each sensitive field is still masked (****) for anyone lacking access to it, and password-typed fields are always masked.
  • Legacy virtual handling. Filters use virtual != true (not virtual == false) so pre-existing rows without the field are still returned.

Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27