Document Templates

Generate professional PDF documents from form submissions using customizable templates with field variables, conditional formatting, and colored text

What This Feature Does

Document Templates allow you to create professional PDF documents from form submissions. Instead of manually copying data into Word or Excel, you define a template once and generate polished documents automatically. Templates can include your branding, formatted layouts, conditional formatting with colors, and all the data from form submissions.

Understanding Templates

How Templates Work

  1. Create a template with placeholders for form fields
  2. User submits a form with their data
  3. Generate document that replaces placeholders with actual values
  4. Download or share the completed PDF

Template Components

  • Static Content: Text, images, and formatting that appear on every document
  • Field Variables: Placeholders replaced with submission data using ${field_name} syntax
  • Conditional Expressions: Show different text based on field values using ternary syntax
  • Colored Text: Apply colors to conditional results for visual emphasis
  • Table Variables: Repeat data from Table fields

Creating a Template

Setting Up Your First Template

  1. Navigate to "Forms" in the left sidebar
  2. Select the form you want to create a template for
  3. Click the "Templates" tab
  4. Click "Create Template"
  5. The template builder opens

Template Builder Interface

Left Panel - Field Variables

  • Lists all fields from your form
  • Click to insert variable at cursor position
  • Shows the variable syntax for each field

Center Canvas - Template Editor

  • Rich text editing area
  • WYSIWYG formatting (bold, italic, headings, lists, tables)
  • Live preview of template with sample data

AI Generation

  • Use the AI generator to auto-create a template based on your form fields
  • Review and customize the generated template

Field Variables

Basic Variable Syntax

Insert form data using the ${field_name} syntax. Click a field in the left panel to insert it at your cursor, or type it manually.

Example:

Site Inspection Report

Location: ${site_location}
Date: ${inspection_date}
Inspector: ${inspector_name}

When a form is submitted, each ${field_name} is replaced with the actual value from the submission.

How Variables Are Resolved

  • Variables match the field name set in the form builder
  • If a field has no value in the submission, the variable placeholder remains as-is
  • Field names can contain letters, numbers, underscores, and hyphens (e.g., ${fileupload-e76})

Conditional Formatting

Conditional expressions let you display different text depending on a field's value. This is useful for showing status labels, pass/fail indicators, yes/no answers, and more.

Basic Conditional (Truthy/Falsy Check)

Show one value when a field has data, another when it doesn't:

${field_name ? "Yes" : "No"}

How it works:

  • If field_name has a value → displays Yes
  • If field_name is empty or not provided → displays No

What counts as "falsy" (empty/false):

  • Empty string
  • The text false
  • The text no or No
  • The text 0
  • Null or undefined (field has no value)

Everything else is considered "truthy" (has a value).

Examples:

ExpressionField ValueResult
${has_ppe ? "Yes" : "No"}trueYes
${has_ppe ? "Yes" : "No"}(empty)No
${comments ? "See below" : "None"}Looks goodSee below
${comments ? "See below" : "None"}(empty)None

Negated Check

Reverse the condition using !:

${!field_name ? "Not provided" : "Provided"}
  • If field_name is empty → displays Not provided
  • If field_name has a value → displays Provided

Equality Comparison

Compare a field's value to a specific text:

${field_name === "value" ? "Match text" : "No match text"}

Supported operators:

  • === or == — equals
  • !== or != — not equals

Examples:

ExpressionField ValueResult
${status === "Passed" ? "Passed" : "Failed"}PassedPassed
${status === "Passed" ? "Passed" : "Failed"}FailedFailed
${risk !== "Low" ? "Review required" : "OK"}HighReview required
${risk !== "Low" ? "Review required" : "OK"}LowOK

Quote Styles

Both single and double quotes work inside expressions:

${field_name ? "Yes" : "No"}
${field_name ? 'Yes' : 'No'}

Colored Text

You can apply colors to conditional results using the pipe | syntax. Colors appear both in the template preview and in exported PDFs.

Color Syntax

Add a color after the text value, separated by a pipe |:

${field_name ? "text|color" : "text|color"}

Example: Pass/Fail with Colors

Result: ${inspection_passed ? "PASSED|green" : "FAILED|red"}
  • If inspection_passed has a value → displays PASSED in green
  • If inspection_passed is empty → displays FAILED in red

Example: Status with Colors

Risk Level: ${risk_level === "High" ? "HIGH RISK|red" : "Standard|green"}

Example: Yes/No with Colors

PPE Worn: ${has_ppe ? "Yes|green" : "No|red"}
Permit Valid: ${permit_valid ? "Valid|green" : "Expired|red"}
Site Induction: ${site_induction ? "Complete|green" : "Incomplete|orange"}

Available Named Colors

Standard colors:

Color NameExample Use
redErrors, failures, critical items
greenSuccess, passed, approved
blueInformation, links
yellowWarnings, caution
orangeModerate risk, pending
purpleSpecial, premium
pinkHighlights
grayDisabled, not applicable
blackDefault text
whiteLight text on dark backgrounds

Semantic colors (aliases):

Color NameSame AsUse Case
successgreenPositive outcomes
errorredNegative outcomes
dangerredCritical warnings
warningyellowCaution indicators
infoblueInformational items
okgreenApproval indicators
passgreenTest/inspection passed
failredTest/inspection failed

Custom Colors

You can also use hex color codes or RGB values instead of named colors:

${status ? "Active|#22c55e" : "Inactive|#ef4444"}
${status ? "Active|rgb(34, 197, 94)" : "Inactive|rgb(239, 68, 68)"}

Conditional Formatting Reference

Complete Syntax Summary

PatternSyntaxExample
Simple variable${field}${inspector_name}
Truthy check${field ? "yes" : "no"}${has_ppe ? "Yes" : "No"}
Negated check${!field ? "no" : "yes"}${!comments ? "None" : "See below"}
Equals${field === "val" ? "a" : "b"}${status === "Pass" ? "OK" : "Fail"}
Not equals${field !== "val" ? "a" : "b"}${risk !== "Low" ? "Review" : "OK"}
With color${field ? "text|color" : "text|color"}${ok ? "Yes|green" : "No|red"}
Equals with color${field === "val" ? "text|color" : "text|color"}${status === "High" ? "High|red" : "Normal|green"}

Important Notes

  • Field names are case-sensitive${Status} and ${status} are different
  • Values inside quotes are compared as plain text
  • The color part (after |) is optional — you can have colored true values and plain false values, or vice versa
  • If a variable is not found in the form data, the placeholder text ${field_name} appears as-is in the output
  • Colors work in both the live template preview and the exported PDF

Table Data

For forms with Table fields, you can insert a table variable that automatically generates rows from the submitted data.

Inserting a Table Variable

  1. Click a Table field from the left panel
  2. The template inserts ${table_field_name}
  3. When rendered, this is replaced with a full table showing all submitted rows

How Table Variables Work

  • Each column from the Table field becomes a column in the output table
  • Each row of submitted data becomes a row in the output table
  • The table is formatted automatically in the PDF

Rich Text Formatting

The template editor supports full rich text formatting that is preserved in the PDF output:

  • Bold, italic, underline, and strikethrough text
  • Headings (H1, H2, H3)
  • Bullet lists and numbered lists
  • Tables (static content tables, not to be confused with Table field variables)
  • Blockquotes
  • Horizontal rules
  • Images

All formatting is preserved when generating the PDF document.


Template Examples

Safety Inspection Report

SAFETY INSPECTION REPORT

Date: ${inspection_date}
Location: ${site_location}
Inspector: ${inspector_name}

---

INSPECTION SUMMARY

Overall Result: ${overall_status === "Passed" ? "PASSED|green" : "FAILED|red"}
Risk Level: ${risk_level === "High" ? "HIGH RISK|red" : "Standard|green"}

PPE Compliance: ${ppe_compliance ? "Compliant|green" : "Non-compliant|red"}
Permit on Display: ${permit_displayed ? "Yes|green" : "No|red"}
Fire Extinguisher Checked: ${fire_extinguisher ? "Yes|green" : "No|red"}

---

INSPECTION ITEMS

${inspection_items}

---

ADDITIONAL COMMENTS

${comments ? "See comments below" : "No additional comments"}
${comments}

---

Inspector Signature: ${inspector_signature}
Date: ${submission_date}

Daily Site Diary

DAILY SITE DIARY

Project: ${project}
Date: ${diary_date}
Weather: ${weather_conditions}

---

PERSONNEL ON SITE

${workers_table}

---

WORK COMPLETED TODAY

${work_description}

---

ISSUES OR DELAYS

${!issues ? "No issues reported" : "Issues recorded — see below"}
${issues}

---

Submitted by: ${submitted_by}

Equipment Checklist

EQUIPMENT INSPECTION CHECKLIST

Equipment ID: ${equipment_id}
Equipment Type: ${equipment_type}
Inspection Date: ${inspection_date}
Inspector: ${inspector_name}

---

CHECKLIST RESULTS

Brakes: ${brakes_ok ? "Pass|pass" : "Fail|fail"}
Lights: ${lights_ok ? "Pass|pass" : "Fail|fail"}
Tyres: ${tyres_ok ? "Pass|pass" : "Fail|fail"}
Hydraulics: ${hydraulics_ok ? "Pass|pass" : "Fail|fail"}
Seatbelt: ${seatbelt_ok ? "Pass|pass" : "Fail|fail"}
Horn: ${horn_ok ? "Pass|pass" : "Fail|fail"}

Overall Status: ${overall_passed ? "CLEARED FOR USE|success" : "DO NOT OPERATE|danger"}

---

Notes: ${!notes ? "None" : "See below"}
${notes}

Inspector Signature: ${inspector_signature}

Generating Documents

From a Single Submission

  1. Navigate to Submissions
  2. Open the submission you want to generate a document for
  3. Click "Generate Document"
  4. Select the template to use
  5. Click "Generate"
  6. PDF downloads or opens in a new tab

Bulk Generation

Generate documents for multiple submissions:

  1. In the submissions list, select multiple rows
  2. Click "Bulk Actions"
  3. Select "Generate Documents"
  4. Choose template
  5. Click "Generate"
  6. Download ZIP file with all PDFs

Automated Generation via Workflow

Generate documents automatically on submission:

  1. Set up a Workflow
  2. Add "Generate Document" action
  3. Select template
  4. Configure delivery:
    • Attach to submission
    • Email as attachment
    • Save to storage

Managing Templates

Editing Templates

  1. Navigate to form's "Templates" tab
  2. Click on template to edit
  3. Make changes
  4. Save template

Duplicating Templates

  1. Click actions menu on template
  2. Select "Duplicate"
  3. Modify the copy as needed
  4. Save with a new name

Deleting Templates

  1. Click actions menu on template
  2. Select "Delete"
  3. Confirm deletion

Note: Deleting a template doesn't affect already-generated documents.


Troubleshooting

Variables aren't being replaced

  • Verify the syntax uses dollar sign and curly braces: ${field_name}
  • Check that the field name matches exactly (case-sensitive)
  • Ensure the field has a value in the submission

Conditional expression isn't working

  • Make sure quotes surround both the true and false values: ${field ? "Yes" : "No"}
  • Check that the comparison value matches exactly (case-sensitive)
  • Verify you're using the correct operator (=== for equals, !== for not equals)

Colors aren't showing

  • Make sure the color comes after a pipe character: "text|green" not "text green"
  • Check the color name is spelled correctly (see the named colors table above)
  • If using hex codes, include the hash: "text|#22c55e" not "text|22c55e"

Table variable shows placeholder text

  • Verify the Table field has data in the submission
  • Check that ${table_field_name} matches the exact field name

PDF layout issues

  • Check page margins
  • Reduce image sizes
  • Simplify complex formatting
  • Test with less content

Best Practices

  • Test with sample data: Use the live preview to verify your template before generating real documents
  • Use colors sparingly: Reserve colored text for important status indicators (pass/fail, yes/no)
  • Name fields clearly: Use descriptive field names so variables are easy to identify in the template
  • Keep it readable: Don't overcrowd templates with too much data
  • Consider printing: Test how documents look when printed
  • Use conditional formatting for compliance: Highlight non-compliant items with red and compliant items with green

What's Next

After creating templates, you may want to: