Skip to content

Send filtered email reports to other people ​

A system filter is a table filter that belongs to no one. Linked to a scheduled job, it emails its results every day to the people the records point to — for example each buyer gets their own open purchase orders. Only super administrators see these options; users who want a filter for themselves link their own saved filter.

1. Filter the list ​

Open the list, click the filter icon next to its title and set the filters and visible columns the email should use. Here: Purchase orders, filtered by Status. Only the filters and columns matter — sorting is ignored.

The Status filter added under Selected filtersThe Status filter added under Selected filters

2. Create the system filter ​

Click Create system filter & link to job and fill in:

  • Select scheduled job — Send daily filtered email report (runs every day at 01:00).
  • System filter name — shown in the email subject, e.g. Open orders per buyer.
  • Email path — where each record keeps the address to send to (see the table below).
  • Email template — optional (see below).

A system filter that emails each buyerA system filter that emails each buyer

Email pathWho gets the email (purchase orders)
user.emailthe buyer who created each order
partner.emailthe supplier of each order
user.email, [email protected]the buyer, plus a fixed address on every email

Write the path from the record to an email field, separated by dots. It can go through several records, e.g. sales_person.user.email on sales orders; through a list of records (e.g. all assigned users) it sends to each of them. Separate several paths or fixed addresses with commas. Records with no valid address are skipped, and a field holding several addresses separated by commas sends to each.

3. Save it ​

Click Create & link to job.

The system filter is created and linkedThe system filter is created and linked

4. What gets sent ​

Every day the job runs the filter and groups the matching records by their email address:

Email templateWhat every address gets
noneone email with an Excel file of only its records — the filter's visible columns
without a [records] blockone email per record, written from the template, no Excel file — e.g. a reminder per overdue order
with a [records] blockone email listing all its records, written from the template, no Excel file — e.g. a weekly digest per buyer

If nothing matches, nobody gets an email.

5. Set up the email template ​

Create the template under Templates as described in Create a template. For these emails it needs:

  • Template type — Mail, and Active turned on.
  • Document type — the same model as the list the filter is on (Purchase orders here). The email looks each record up in the template's document type, so a template for another model sends the wrong data or fails.
  • Template engine — placeholder or twig (examples for both below).
  • Subject — the email subject. [placeholders] work here with either engine, e.g. Open order [document_number].

One email per record. Placeholders are filled from that record:

html
<p>Purchase order [document_number] for [partner.short_name] is still open.</p>
<p><a href="[frontend_url]/orders-purchase/[id]">Open the order</a></p>

One email per address, listing its records. Put the records in a table: a row with [records], the row to repeat, and a row with [/records] (use Start element / End element in the editor, or type them). Inside, write fields as [records.<field>]:

html
<p>These purchase orders are still open:</p>
<table>
  <tr><th>Document no.</th><th>Supplier</th></tr>
  <tr><td>[records]</td><td></td></tr>
  <tr>
    <td><a href="[frontend_url]/orders-purchase/[records.id]">[records.document_number]</a></td>
    <td>[records.partner.short_name]</td>
  </tr>
  <tr><td>[/records]</td><td></td></tr>
</table>

Placeholders outside the [records] block (and in the Subject) take the first record of that address.

Twig templates (see Write a Twig template) get record — the record, or the first one of that address — and records, the list of all of them. A template that uses records in a tag sends one email per address; any other sends one email per record:

twig
<p>These purchase orders are still open:</p>
<ul>
  {% for order in records %}
    <li>{{ order.document_number }} — {{ order.partner.short_name }}</li>
  {% endfor %}
</ul>

Then pick the template under Email template when you create or edit the system filter. The list shows active mail templates for the list's model.

A template that lists each buyer’s orders in one emailA template that lists each buyer’s orders in one email

IMPORTANT

If no mail template exists for the list's model, Email template lists all mail templates. Don't pick one made for another model — create one for this model first.

6. Change or remove a system filter ​

System filters are listed under System filters, with their job and email path. Click the pencil to rename it or change the email path or template; click the bin to delete it, which also stops its emails.

The system filter with its job and email pathThe system filter with its job and email path

Editing a system filterEditing a system filter

WARNING

Picking a different job here links the filter to that job as well — it does not unlink the old one. Unlink it on the scheduled job (next step).

7. See everything linked to the job ​

Go to Admin › Scheduled jobs and open Send daily filtered email report. The Linked filters section lists every linked filter — system filters and users' own — with its email path. Click Linked filters to expand it, and the unlink icon to stop a filter's emails.

Linked filters on the scheduled jobLinked filters on the scheduled job