---
title: "Report Concepts"
url: "https://dev.4hse.com/guides/reports/report-concepts"
description: "The concepts behind 4HSE reports (version v2): what a report is, its parts, launch points, how it runs, template, helpers and partials, the debug entity."
---

# Report Concepts

This page explains the concepts 4HSE reports are built on. To write a report see [Coding Reports](/guides/reports/coding-reports/); to use the tool it is written with see [Report Editor](/guides/reports/report-editor/).

## What is a report

[Section titled “What is a report”](#what-is-a-report)

A **report** turns 4HSE data into a printable document: a data sheet, a register, a certificate, a list. Users run it from the print button of a record or of a list (and from the file manager); the report loads its own data and renders it with an HTML + [Handlebars](https://handlebarsjs.com/) template. The document can be saved as HTML (viewable in a browser, convertible to PDF or Word) or, for some reports, as CSV or plain text. How a user chooses and prints a report is in the user guide: [Printing and exporting](https://docs.4hse.com/reports/).

A report is a JSON file with the `.ht` extension.

## The parts of a report

[Section titled “The parts of a report”](#the-parts-of-a-report)

A report is made of five parts: metadata, script, template, helpers and partials.

### Metadata

[Section titled “Metadata”](#metadata)

The **metadata** tell when and where the report is offered:

Metadata

What it says

**Name** and **description**

how the report presents itself in the picker

**Tags**

labels to filter the list of reports

**Launch points**

the places in the app the report can be printed from

**Country** and **language**

for people working in which country and language the report is offered

**Output type**

the format of the document: HTML, CSV or plain text

#### Launch points

[Section titled “Launch points”](#launch-points)

Every place in the app from which a report can be printed is a **launch point**, identified by a **target**. The picker shows only the reports whose `target` contains the current launch point, so a report must list every launch point it supports. A report with no launch points never appears in a picker. How users see them in the list of reports: [Search for a report](https://docs.4hse.com/reports/choose-a-report/#search-for-a-report).

Kind

Examples

The item the report receives

Record

`office`, `person`, `equipment`, `substance`, `work_environment`, `incident`, `supplier`, `supplier_office`, `org_safety`, `hgroup`, `job`, `work_place`, `ppe`, `ppe_item`

that record

Action family

`action_<type>`, `action_session_<type>`, `action_session_date_<type>`, `action_subscription_<type>`, `action_session_subscription_<type>`, `certificate_<type>` with `<type>` = `training`, `health`, `maintenance`, `per`, `check`

that record

List in a scope

`office.equipment_list`, `office.person_list`, `office.ppe_list`, `project.person_list`, `project.supplier_list`…

the office or the project, **not** the rows: the report loads the list itself

Global list

`person_list`, `supplier_list`, `project_list`

none

#### Country and language

[Section titled “Country and language”](#country-and-language)

`country` and `lang` are filters the user can change in the picker (by default: the country of the context and the user’s language). They are permissive: a report with an empty `country` matches every country, one with an empty `lang` matches every language. The filters in the picker are described in [Search for a report](https://docs.4hse.com/reports/choose-a-report/#search-for-a-report).

### Script

[Section titled “Script”](#script)

The **script** is the JavaScript that loads the data: it defines the `onInit` function, which reads the data from 4HSE and returns an object. That object is the context of the template.

### Template

[Section titled “Template”](#template)

The **template** is the document: HTML (or text, according to the output type) with Handlebars expressions between double braces, `{{...}}`. Its context is the object returned by `onInit`. Handlebars is deliberately poor in logic: prepare the data in the script and leave the layout to the template.

### Helpers

[Section titled “Helpers”](#helpers)

A **helper** is a function the template calls to format or compute a value. There are two kinds: the **built-in** ones of 4HSE (for example `dateFormat`, `t`, `qr`, `eachSort`), available in every report, and the **report-specific** ones, written in the `helpers` field and valid only in that report.

### Partials

[Section titled “Partials”](#partials)

A **partial** is a piece of template kept in a separate file and reused by one or more reports, so you write it once: a common header with the logo and the company data, a signature block, a table that appears in several documents. Changing the partial changes every report that includes it.

A partial is declared with an **alias** (the name used in the template) mapped to a file, and included in the template with `{{> alias}}`. It has no data of its own: it uses the data returned by the script of the report that includes it.

## How a report runs

[Section titled “How a report runs”](#how-a-report-runs)

When the user picks a report and the preview opens, 4HSE runs these steps in order:

1.  **Partials**: every file declared in `partials` is read and kept as text.
2.  **`onInit`** runs and returns the data.
3.  **Helpers**: the code in `helpers` is evaluated and its `helpers` object is added to Handlebars.
4.  **Template**: it is compiled and rendered with the data. The result is the document.

The steps run in this order every time the report is generated.

The three code fields do not share variables. What `script` declares stays inside the script, `helpers` is evaluated in the global scope of the page, and `template` only sees the data: whatever the template needs has to be returned by `onInit`.

If a step fails, the run stops and the error tells where it happened (`script`, `helpers` or `template`).

## Debug entity

[Section titled “Debug entity”](#debug-entity)

The **debug entity** is the item a report is tested with in the editor. A report is always generated for a given item (a piece of equipment, an office…), so to see it in the preview you choose one, together with the launch point you imagine it launched from. The report sees them as `this.runtime.context` and `this.runtime.target`.

This site is protected by reCAPTCHA and the Google [Privacy Policy](https://policies.google.com/privacy) and [Terms of Service](https://policies.google.com/terms) apply.