Template will not save, publish or render: a tag, expression or the HTML is wrong
A document template, message template or rule action that carries a broken merge tag is refused when saved or published, names the field and the line; a template that parses but fails while filling in a record, or whose HTML the PDF or Word engine cannot lay out, fails at preview, generation or sending; the editor's own dialogs and fields have their own checks.
Messages this explains
- “body_html: <parser message> (line <n>)”
- “header_html: <parser message> (line <n>)”
- “footer_html: <parser message> (line <n>)”
- “title_template: <parser message> (line <n>)”
- “subject: <parser message> (line <n>)”
- “body: <parser message> (line <n>)”
- “actions[<n>].config.<field>: <parser message> (line <n>)”
- “The HTML exceeds 500 KB”
- “Please correct the highlighted fields.”
- “Template could not be rendered: <error>”
- “PDF could not be produced: <error>”
- “Word document could not be produced: <error>”
- “Choose what to repeat over.”
- “The row name may contain letters, digits and underscores.”
- “Put the cursor inside a table row first.”
- “Write a condition.”
- “Put the cursor inside the block to wrap.”
- “The extra context is not valid JSON.”
- “Choose an entity to preview the template against.”
- “Create the template first; it then renders here against any record.”
- “Use at most 10 characters”
- “Letters and digits only”
Template will not save, publish or render: a tag, expression or the HTML is wrong
You pressed Save draft, Publish, Preview, Open PDF, Generate or Save changes on a template, and the app refused because a merge tag does not parse, a value cannot be filled in, the HTML is too large or cannot be laid out, or one of the editor's dialogs needs something first.
What you see
On the Document template page:
- Save draft and Publish fail with "body_html: <parser message> (line <n>)", for example "body_html: unexpected '}' (line 3)", when a merge tag or a condition or loop tag in the body does not parse. The same message names "header_html" or "footer_html" for the header and footer overrides, and "title_template" for the Document title. It appears in the red alert at the top and in the form banner.
- Publish fails with "Please correct the highlighted fields." when the body is empty (the server's reason, "Add content before publishing.", is not shown on a field because the body is not a form field). Save draft shows the same message when a field is over its length limit: the body over 500,000 characters, a header or footer override over 100,000.
- "The HTML exceeds 500 KB" appears on Publish, Preview or Open PDF, or when a document is generated or an email is sent, when a body saved just under the 500,000-character limit ends up over it once the app has cleaned its HTML. Pasted images, which are stored inside the HTML, are the usual cause.
- Preview and Open PDF fail with "Template could not be rendered: <error>" when the template parses but a value cannot be worked out for the chosen record (a filter given the wrong kind of value, a comparison of text with a number…), and with "PDF could not be produced: <error>" when the layout engine cannot handle the HTML or CSS.
- The Number prefix field refuses "Use at most 10 characters" and "Letters and digits only".
- The Repeat row dialog refuses "Choose what to repeat over.", "The row name may contain letters, digits and underscores." and "Put the cursor inside a table row first."; the Show when dialog refuses "Write a condition." and "Put the cursor inside the block to wrap."
On Generated documents and a record's documents card (for example Booking documents), Generate, Preview, Download PDF and Download Word fail with "Template could not be rendered: <error>", "PDF could not be produced: <error>" or "Word document could not be produced: <error>".
On Message template and New message template:
- Save changes and Create template fail with "subject: <parser message> (line <n>)", "body: <parser message> (line <n>)" or "body_html: <parser message> (line <n>)", one per field.
- The Preview panel shows "The extra context is not valid JSON." when the extra context you pasted is not JSON, "Choose an entity to preview the template against." when the server gets no record type for a template that has none, and "Template could not be rendered: <error>" when the saved template fails against the chosen record. On a template that is not created yet the panel reads "Create the template first; it then renders here against any record."
On a Rule, Save changes fails with "actions[<n>].config.<field>: <parser message> (line <n>)" on the action's card, for example "actions[0].config.subject: unexpected end of template (line 1)". Actions are counted from 0.
When a workflow rule generates or emails a document and the template fails, the run errors with the same "Template could not be rendered" or "PDF could not be produced" text; see Workflow runs.
Why it happens
Templates are checked twice. When you save or publish, every field that may carry merge tags is parsed: an unclosed merge tag, a condition without its end tag, a stray brace or a typo in a tag stops the save, with the field name and the line so you can find it. A template that would break on every record is never allowed into use.
Parsing cannot know what a record will contain. Filling in happens at preview, generation and sending, and that is where a valid tag can still fail: an amount filter applied to a field that holds text, a comparison of a date with a number, a loop over something that is not a list. The renderer stops with the underlying error rather than produce a wrong letter; missing values on their own do not fail (they render blank).
The PDF and Word engines take the rendered HTML. CSS or nesting they cannot lay out (unusual positioning, broken tables, unsupported fonts) fails there, after the merge succeeded. Word output is a plain conversion of the body and keeps less of the layout than the PDF.
The size limit keeps rendering, storage and email within bounds: 500,000 characters for a body, 100,000 for a header or footer override. Pasted images are stored inline in the HTML and are the usual cause. The app also cleans the HTML it stores (it strips scripts and adds safe link settings), which can push a body saved right at the limit over it.
The dialogs need a cursor position because Repeat row wraps the table row under the cursor and Show when wraps the block under it; the row name becomes a variable, so it must be a plain identifier. The Number prefix becomes part of every document number ("<prefix>-<n>"), hence letters and digits only, at most 10.
How to fix it
- Find the line. In the editor press View HTML (or read the merge tags in the body) and go to the line the message names; the count is over the stored HTML, so the line is approximate for long paragraphs. Fix the tag: close every merge tag with the same kind of brace it opened with, end every condition and every loop with its end tag (the Show when and Repeat row tools add both ends for you), and use only the fields listed under Merge fields. Then Save draft again. You need the Edit permission on Document Templates (for message templates, the Edit permission on Message Templates; for rules, the Edit permission on Workflow Rules).
- For an empty body on Publish, write or paste the content first, Save draft, then Publish (the Publish permission on Document Templates).
- For a rendering error, read the text after "Template could not be rendered:". It names the filter or operation that failed. Check the record you previewed against: use the Preview with a record that has the values filled, apply the amount filters listed under Formatting in Merge fields (inr, words) to amounts only and date to dates only, and guard optional parts with Show when.
- For a PDF or Word failure, simplify the HTML around the place named after "PDF could not be produced:": remove pasted styling from other programs, keep tables regular (no cell that spans past the row), and use the fonts offered under Font. Re-run Preview, then Open PDF.
- For the size limit, remove or shrink pasted images (put the logo on the Letterhead instead of the body), delete hidden pasted markup with View HTML, and save again.
- In Repeat row, click inside a cell of the row to repeat, choose the list under Repeat over and keep the Row name a single word (letters, digits, underscores). In Show when, click inside the paragraph or table to wrap and type the condition, usually a merge field that may be empty, such as the record's parking slots.
- In the message template preview, paste a JSON object with optional input and event keys, as the box's hint says, or leave the box empty; choose the record type and a record, then Preview. Save your edits first: the preview renders the saved version.
- For a workflow rule, open the action card the message names (the first action is "actions[0]"), correct the field and Save changes.
Related
Related
- Document templateScreen
The template designer: write a template's wording with merge fields, set its letterhead, title and page layout, preview it against a real record, and publish, retire or restore its versions.
- Generated documentsScreen
The organization-wide log of every document generated from a template or uploaded against a record, where you preview, download, email, void or delete them.
- Message templateScreen
One message template's page: change its wording, attachments and settings, and preview it filled in for a real record.
- New message templateScreen
Write a message template on its own page: code, name, channel, record type, subject, the designed email body and its plain-text version, attachments, and the merge-field reference.
- RuleScreen
One automation rule's page: read or change its basics, trigger, conditions and actions, test it against a record, clone or delete it, and switch a system rule on or off.
- RunsScreen
Every time a rule ran: what started it, which record it worked on, how each action went, and the panel from which an errored run is retried.
- LetterheadsScreen
Set up the branding wrapped around generated documents: logo, header and footer, page size, orientation, margins and page numbers, for the whole organization or for one project.
- Booking documentsScreen
The letters and agreements generated for one booking, such as the allotment letter, together with the receipts of its payments and the letters of its demands, with the button to generate another from a published template and the icons to preview, download, email, void or delete each one.
- Template, letterhead or generated document cannot be deleted: retire or void it insteadTroubleshooting
A document template that produced documents, that an email template attaches or that a workflow rule uses is kept for history and is retired rather than deleted; a letterhead is deleted only once no template uses it; a generated document that was sent is voided, never deleted.
- Email shows as logged or refused: the mail server is not configured or rejected the messageTroubleshooting
Outgoing mail is sent through a mail server set up for the installation, not inside the app; while none is configured every email (document, campaign, workflow, invitation, verification) is only logged and reported as not delivered, and when the server refuses a message the recipient is marked failed; the person who runs the installation configures mail, then you resend.