π§ What Are Merge Fields? β
Merge Fields (MF) are dynamic placeholdersβtemplate tagsβthat allow the insertion of live, contextual data into documents, emails, and other templates rendered by the ALX system. They are powered by the Jinja2 templating engine to provide greater flexibility and readability.
Merge Fields are resolved at render time and replaced with actual data pulled from records in the system (e.g., users, documents, tasks).
π Basic Usage Example β
{{ user.first_name }} {{ user.last_name }}
{{ document.title }}
{{ base64(document.content) }}Merge Fields can also contain conditional logic or loops:
{% if user.is_admin %}
Administrator: {{ user.email }}
{% endif %}π¦ Technical Foundation β
Jinja2 Template Engine
Merge Fields in ALX are implemented using Jinja2, a fast and expressive templating engine for Python. It provides the syntax and context resolution needed to work with dynamic fields.
π Jinja2 Official Documentation
π― Purpose of Merge Fields in ALX β
Merge Fields serve as a dynamic link between your data and rendered content in ALX. They are frequently used in:
- Document generation - document templates
- Email templates and system notifications
- Sequencer Actors: API Call, Send Message, Variables, AI Actors
- Web-based dynamic content views
- Word Add-in plugin
Merge Fields allow you to write generic templates that adapt to the actual content of a record at runtime. Merge fields allow inserting Object Record data in document templates, API call actor parameters, emails, and other resources relevant to Object Records.
π§© Overview of Supported Merge Field Types β
The ALX system supports a wide range of Merge Fields. Detailed sections will follow, but broadly, MF types include:
User merge fieldsβ full user objects, user groups, active-only usersDocument merge fieldsβ metadata and file contentsBase64 merge fieldsβ useful for embedding files in templatesRecord propertiesβ access any custom field from a recordSystem fieldsβ like current date, time, or logged-in userRelated recordsβ for accessing nested relationshipsLoop Itemβ for accessing items from Loop actor
βοΈ System Merge Fields β
System merge fields are global system variables that are available in every context regardless of the currently processed object (record, user, etc.). They are not tied to any specific object and contain information about the system, environment, and execution context. The system merge fields are organized into four main categories:
π€ Admin Context β
Admin-related merge fields provide information about the system administrator:
π Example usage β
{{ admin_first_name }}
{{ admin_last_name }}
{{ admin_email_address }}
{{ admin_phone_number }}
{{ admin_job_title }}
{{ admin_email_signature }}π’ Client Context β
Client-related merge fields provide information about the current client:
{{ client_name }}
{{ client_url }}π Date and Time Context β
Date and time merge fields provide current temporal information:
{{ current_date }}
{{ current_datetime }}π§ Constants Context β
Constants are user-defined values available throughout the system with special prefix constants:
{{ constants.API_BASE_URL }}
{{ constants.COMPANY_NAME }}
{{ constants.SUPPORT_EMAIL }}π Loop Item Context β
The loop_item merge field is a dynamic reference to the currently processed item within a Loop actor. Loop Item is user-defined value available throughout the system with special prefix loop_item:
{{ loop_item }}
{{ loop_item.name }}
{{ loop_item.key1.key2 }}βοΈ Usage Contexts β
System merge fields work in all places where merge fields are supported:
- Document templates
- Email templates
- Sequencer (all actors)
- API responses
- Workflow notifications
- Custom scripts
π Complete Usage Example β
Template:
Dear {{ client_name }},
This email was sent by {{ admin_first_name }} {{ admin_last_name }} on {{ current_date }} from {{ client_url }}.
API endpoint: {{ constants.API_BASE_URL }}/users
Best regards, {{ admin_email_signature }}Output:
Dear Acme Corporation,
This email was sent by Joe Doe on 2020-02-05 from [http://client.testserve](http://client.testserve).
API endpoint: https://api.example.com/users
Best regards, SignatureGlobal Availability
π All system merge fields are globally available and don't require any specific object context to function.
Constants Prefix
β οΈ Constants merge fields require the constants. prefix, while other system merge fields can be used directly without prefixes.
π§Ύ Summary β
Merge Fields are a core part of dynamic content generation in ALX. Backed by Jinja2, they allow templates to remain generic and adaptable while still outputting rich, data-driven content. Understanding how they work is essential to building powerful document templates and user-facing messages.
π What's Next? β
A specific and powerful category of merge fields relates to Object Recordsβthese include field references, nested relationships, and dynamic access to custom properties.
π§ These will be covered in detail in the Object Record Merge Fields, where we explain how to access and format data from related records, such as linked users, documents, or custom model instances.