Using a Template in a Workflow
Use the Template activity to fill a published template with workflow data and pass the result to a later activity, such as a REST call or an email. The activity uses one version of the template until you choose another.
Before you begin
- Publish the template. The activity lists only templates with a published version. Drafts are not offered.
- Open the workflow in the workspace that can use the template: a Workspace level template for that workspace, or any Organization level template.
Add the activity
- Add the Template activity from the Common group to the workflow.
- In the Template field, search for and select a template. The list shows each template with its type. Search matches name, type, level, and description.
- Check the version list that appears next to the template. Studio selects the latest published version, shown as, for example, v3 (latest).
- Map the template's placeholders as the activity's input. The activity builds the input fields from the placeholders in the template.
- Map the result as the activity's output to the next activity. The output is
useTemplateOutput.output.
The Template field lists the organization's templates and the templates of the workspace you are in.
An Organization template shows (Organization) after its name. When two templates share a name, the label adds (Workspace) or (Organization), and identical names at the same level add a short code in brackets.
What the output contains
| Template type | useTemplateOutput.output |
|---|---|
| JSON | The parsed JSON, so you can map its fields. Placeholder values are escaped as the inside of a JSON string. |
| XML | A string. Placeholder values are escaped for markup. |
| HTTP (HTML) | A string. Placeholder values are escaped for markup. |
| Text | A string. Nothing is escaped. |
Write {{{x}}} to skip escaping for XML and HTTP (HTML) templates.
Keep or change the version
The activity stays on the version you picked. Publishing a new version does not change it.
When a newer version exists, the field shows Pinned to vN. vM is available. Select Use vM to move to it. Check the Input mapping afterward, because the new version may read different placeholders.
How you know it worked
The output mapping shows a schema under useTemplateOutput.output, and a test run returns the rendered text. To check without deploying, see Run a Draft Execution.
When it does not work
| Symptom | Cause | What to do |
|---|---|---|
| The Template list shows No published templates yet. Create one in Settings > Templates | No template has a published version. | Publish a version. |
| The Template list shows No templates match | Your search matches no published template. | Change the search text. |
| The selected template version is no longer available. Choose another. | The version was deleted, or you no longer have access. | Select another template or version. |
| This step still uses a template resource. Choose a template above to replace it. | The step was built with an older template resource. | Select a template in the Template field. |
TEMPLATE_VERSION_NOT_FOUND | The version was deleted, is a draft, belongs to another organization or workspace, or the reference is malformed. A deployment also stops early and names the missing version. | Select a published version and redeploy. |
TEMPLATE_RESOURCE_NOT_FOUND | No template is set on the step, or the template resource it points to is missing. | Select a template in the Template field. |
TEMPLATE_SYNTAX_ERROR or TEMPLATE_RENDER_ERROR | The template text fails when it runs, for example an unknown helper. | Fix the template, publish a new version, and select it. |
TEMPLATE_INVALID_JSON_OUTPUT | A JSON template rendered text that is not valid JSON. The error names the line and column. | Check commas, quotes, and braces around placeholders. |
TEMPLATE_UNSUPPORTED_TYPE | The template type is not supported. | Use JSON, XML, HTTP (HTML), or Text. |
TEMPLATE_STORE_UNAVAILABLE | The template store could not be reached. Whether it is retried depends on the retry policy. | Retry the run. |
Deployments and deleting
When you deploy a workflow, the template versions it uses are recorded with the deployment. A template with a deployed or pending workflow cannot be deleted. See Managing Template Versions.