A Template value formatter can return formatted HTML or change another part of the document based on a merged value. Use this for conditional sections and formatted merge content that must carry through to Redlining, signing and the PDF.
These techniques apply to Templates and Redlining. 3B Sign formatters receive a value and field configuration, but do not receive a Template document element. See Value formatters for the arguments supported by each app.
The formatter receives an arguments object. args.value is the merged value and args.element is its merge element. Find other content through args.element.ownerDocument, which is the document being generated.
Use the Template builder's Source code tool to give the target content an identifier. This illustrative paragraph uses optional-section:
<p id="optional-section">Optional terms go here.</p>
Apply a formatter to the merge field that controls whether this paragraph is shown. This example hides it when that field contains Hide; replace the condition with the value used in your own document:
(args) => {
if (args.value === 'Hide') {
args.element?.ownerDocument
?.querySelectorAll('#optional-section')
.forEach((element) => (element.style.display = 'none'));
}
return args.value;
}
Keep the controlling merge field in the Template and save the Template after editing its markup. Return args.value when the formatter changes another element but should leave its own merged value intact.
Apply styles directly to the generated elements. Avoid searching the surrounding web page with document.querySelector(...) or inserting styles into that page: the signing interface may not exist when the formatter runs, and page-only changes are not saved with the document. If hiding a nested element leaves an empty paragraph, target its containing paragraph instead.
From version 10.11.0, the Redlining editor preserves the HTML returned inside a merge field, including styled spans and tables, when it loads and saves the working document. Previously, it could reduce that content to plain text or lose parts of it, affecting the later signing view as well.
Merge fields remain read-only within the redlining editor. Collaborators cannot edit the content inside them. The retained HTML carries through to the saved document and PDF; the selected PDF engine's rendering limits still apply.
| Workflow | When the document is generated |
|---|---|
| Single-user Template link | As the submission document loads. |
| Redline Request | When the request is first opened and its working document is generated. Later visits reuse the saved Document.html. |
Editing a formatter does not regenerate an existing Redline Request. A request that already lost formatting when saved in an older editor is not repaired automatically by upgrading. Create a new request to generate the document with the current formatter and preserve its HTML from the start.
For troubleshooting, the browser console reports Document not generated, generating now... when Redlining generates a working document, and Document already generated when it uses the saved copy. Failed to parse Expression indicates a formatter evaluation error. Check that the formatter reads args.value and targets args.element.ownerDocument.