A job is a trigger, conditions and an ordered list of actions, set up under Customization › Orchestration in the admin; jobs were called hooks before the module was renamed, and the API's routes keep that name. What starts a job, what it can do, branches and loops, email, scheduled work, integrations with other systems, and every event and action.
L2–L3
Unit 03 · What a job does
Render template and send email
What a job doesPage 12 of 31Updated
Render Template turns a template from the theme repository into text a later action uses: a CSV export, a JSON payload, an email body, a certificate's markup. Send Email queues a message from a template. How each is configured, what it leaves, and where it fails.
Who this is for. Theme developers and integrations engineers producing exports, payloads and messages from jobs. Afterwards you can keep that output in the repository as templates and wire it to the action that sends or saves it.
Render Template
The least obvious action, and the one that unlocks the most. It renders a Template File under templates/hooks/ in the theme repository, or Template Code typed into the action, with every job variable available, and keeps the output as content. That output can be any text: an HTML email body, a JSON payload for the next request, a CSV file, a certificate's HTML. Later actions use it: an HTTP Request sends it, a Create File saves it, a Send Email can repeat it as a body.
Output up to 100,000 characters is kept as content. Longer output is kept in a temporary file for a Create File action to save, and content then holds only the words large file.
The run log shows the first 20,000 characters.
A template error is reported when the job runs, not when it is saved.
A Render Template is also the place for template code that only does something: moving a watermark in site data, setting a value in customData for later actions. Its output is then empty, and that is fine.
A real shape: a nightly CSV
A site that sends its catalogue to a partner every night renders it from a template file: a Retrieve Records find-products, then this Render Template, then a Create File that saves content. Each cell that can hold text is quoted, with quotes inside it doubled:
{strip}
"id","code","available"
{foreach $runData->get('find-products')->records as $product}
{"\n"}{$product->getId()},"{$product->getCode()|replace:'"':'""'}",{$product->getAvailableQuantity()|intval}
{/foreach}
{/strip}
"id","code","available"
{% for product in runData.get('find-products').records %}
{{ product.getId() }},"{{ product.getCode()|replace({'"': '""'}) }}",{{ product.getAvailableQuantity()|integer }}
{% endfor %}
Smarty's {strip} removes the template's own line breaks, so each row's break is printed on purpose with {"\n"}. The step-by-step version, with the file saved and replaced each night, is Build a nightly export as a CSV file. Keep templates like this in the repository rather than typed into the action: they are versioned and reviewed with the rest of the theme, and a long template in an admin field is invisible to both.
Send Email
Field (admin label)
Takes
Recipients, CC (Copy) Recipients, BCC (Blind Copy) Recipients
One per line: an address, Name <address>, or a person's id
Sender
The From address, in the same three forms. Empty means the Mailer's default sender
Reply To Email Address
Where replies go
Subject
Template code
Template file or Template code
The body, one or the other
Every field is template code. The action does not send anything: it puts one message, with all its recipients, on the mailer's queue, and succeeds with the output Mail queued and the mailer's batch id. A worker sends it moments later. The body is sent as HTML when it contains a <body tag and as plain text otherwise. It fails when an address is not one of the three forms, or a person id does not exist (Could not find referenced person with id). There is no attachment field: link to a file the job created instead.
Everything about the message itself, from writing bodies that survive mail clients to testing without mailing a customer, is in the next unit, starting at How a job's email is sent.