Variants

Create dynamic document templates with variable fields

🧩 Variants

Variants in Wraft allow you to define variable fields within a document template. These fields represent dynamic pieces of information that change from one document to another — such as client names, start dates, fees, or project titles.

Overview

Variants make your templates smart and adaptable. Instead of creating a new template for every small change, you define a Variant once and reuse it to generate tailored documents for different scenarios. Additionally, Variants bring together your previously defined components — Layout, Theme, and Flow — into a unified setup that governs the document's structure, appearance, and approval path.

â„šī¸ Info: Variants are at the heart of dynamic document generation — turning static templates into versatile tools.


Creating a Variant

To create a new variant:

  1. Navigate to Variants

    Go to the Variants section in the sidebar

  2. Add New Variant

    Click Add Variant or Create New button

  3. Configure Basic Settings

    • Name: Give your variant a descriptive name (e.g., "Service Agreement Fields", "Employee Contract Variables")
    • Description: Add a brief description of what this variant is used for
  4. Select Template

    Choose the template that this variant will be associated with

  5. Define Fields

    Add the variable fields that will be used in your template


Defining Variable Fields

Variable fields are the dynamic elements that make your templates flexible. When creating fields in your variant:

Field Types

  • Text Fields: For names, addresses, descriptions
  • Date Fields: For start dates, deadlines, contract expiration
  • Number Fields: For amounts, quantities, percentages
  • Selection Fields: Dropdown options for predefined choices
  • Boolean Fields: Yes/No or True/False options

Field Properties

For each field, you can define:

  • Field Name: The identifier used in the template
  • Display Label: The user-friendly name shown in forms
  • Field Type: The type of data expected
  • Required: Whether the field must be filled
  • Default Value: Pre-populated value (optional)
  • Validation Rules: Data format requirements

Connecting Components

Variants serve as the central configuration point where you connect:

Template

The document structure and content that will be generated.

Theme

The visual styling and typography that will be applied to the final document.

Layout

The background design or letterhead that will be used.

Flow

The approval workflow that documents will follow after generation.

This integration ensures that when a document is generated from a variant, it includes all the necessary visual and procedural elements.


Using Fields in Templates

Once you've defined fields in your variant, they can be used in your templates:

  1. Field Syntax: Use the appropriate syntax to reference fields in your template (e.g., {{field_name}})
  2. Field Placement: Place fields anywhere in your template where dynamic content is needed
  3. Field Formatting: Apply formatting rules to ensure proper display

Common Field Patterns

Client Name: {{client_name}}
Contract Date: {{contract_date}}
Project Duration: {{project_duration}} months
Total Amount: ${{total_amount}}

Best Practices

Field Design

  • Use descriptive field names that clearly indicate their purpose
  • Keep field names consistent across different variants
  • Avoid special characters in field names to prevent issues
  • Group related fields logically for better organization

Variant Management

  • Create variants for each document type to maintain organization
  • Test variants thoroughly with sample data before production use
  • Document variant purposes for team reference
  • Version control important variants when making changes

Data Validation

  • Set appropriate field types to ensure data integrity
  • Use validation rules to prevent common data entry errors
  • Provide clear field descriptions to guide users
  • Set reasonable default values where applicable

Common Use Cases

  • Contract terms and conditions
  • Party names and addresses
  • Financial terms and dates
  • Signature requirements

HR Documents

  • Employee information
  • Position details
  • Compensation and benefits
  • Start dates and reporting structure

Sales Documents

  • Client and project information
  • Pricing and terms
  • Deliverables and timelines
  • Payment schedules

Integration with Other Features

Forms

Variants work seamlessly with Forms to collect the data needed to populate template fields.

Pipelines

Pipelines use variants to automate the process of generating multiple documents from a single data source.

Flows

Flows can be attached to variants to automatically route generated documents through approval processes.