AddThisFeature

Mail Merge Documents

Build one document template with placeholders and generate a copy for every record.

involved Documents & Files

What it adds

A template with named placeholders plus a run that produces one rendered document per selected record.

What your agent is told to do

5
  1. 1

    Build the template on the app's existing editor and, if it has one, its Template Picker. Authors should not have to learn a second writing surface to add placeholders.

  2. 2

    Offer placeholders from a defined list of fields on the record type being merged, inserted by picking rather than typed by hand, so a misspelt field name is not possible.

  3. 3

    Render the output documents through the app's existing PDF Export path and deliver a large run as a single archive rather than as hundreds of separate downloads.

  4. 4

    Run the merge as background work with progress, a per-record result, and the ability to retry only the records that failed.

  5. 5

    Do not build a scripting language into the template. Substitution, a fallback value, and a simple present-or-absent section cover the real cases, and anything more becomes a security surface and a support burden.

Edge cases it handles

8
  • A run started with placeholders the data cannot fill produces hundreds of documents with holes in them. Validate the template against the selected records first and show exactly which placeholders are unresolved and how many records are affected.
  • A missing value must not leave a blank gap mid-sentence. Let the author set a fallback per placeholder, or omit the surrounding line entirely, and make the chosen behaviour visible in the editor.
  • A run of several thousand records that fails at record 2900 must not discard the first 2899. Process in batches, record per-record status, and make the whole job resumable.
  • Record data is user-supplied and will contain characters that mean something to the renderer. Escape every substituted value so a name containing markup cannot alter the layout, inject content into other documents, or execute anything.
  • Generating hundreds of documents to discover a broken layout wastes time and money. Require a single-record preview against real data before the full run can be started.
  • Placeholders inside tables, headers, and repeated blocks behave differently from ones in body text and are the usual source of misaligned output. Test those positions specifically.
  • Long substituted values will overflow a line designed around a short one. Define wrapping behaviour rather than letting text run off the page.
  • Each generated document inherits the access rules of the record it came from. A merge output must not be readable by anyone who could not read the source record.

Definition of done

9
  • A template with picked placeholders generates one document per selected record.
  • Unfilled placeholders are reported with affected record counts before the run starts.
  • Missing values resolve to a defined fallback or an omitted line, never a blank gap.
  • Large runs process in batches with per-record status and retry of failures only.
  • Substituted values are escaped and cannot alter the template or output.
  • A single-record preview is required before a full run.
  • Generated documents inherit the access rules of their source records.
  • The feature matches the existing design system.
  • No existing functionality is broken.

Related features

How it works

  1. 1

    Copy the link

    Grab the Markdown instruction URL for this feature.

  2. 2

    Give it to your AI

    Paste it into Claude Code, Cursor, v0, Lovable — whatever you build with.

  3. 3

    It inspects, then implements

    Your agent reads your existing app first, then adds the feature to fit it.

Works with your stack

These instructions are written to adapt. They tell the agent to detect your framework, match your existing design system, and reuse what you already have — rather than assuming a particular stack.

Need it tighter than that? Customize the feature and tell it exactly what you're running.