Skip to main content
Skip table of contents

Word Template Helpers with Word Field Codes

When creating templates in Microsoft Word, Fields act as placeholders (bookmarks) to dynamically insert data from eBECAS/EDMISS. During the merge process, data is inserted exactly as it is, without any logic or advanced formatting. While this is sufficient in most cases, there may be situations where you need to apply conditional logic or formatting based on the merged data. This is where Microsoft Word Field Codes become useful.

This article applies only to templates created in Microsoft Word. For online templates, refer to this article: Template Helpers.

What Are Word Field Codes?

MS Word Fields alone are limited to inserting raw data without additional logic or formatting. To enhance their functionality, MS Word Field Codes which extends MS Word Fields' functionality can be used to dynamically process and format the inserted data.

CODE
{ MERGEFIELD student-dob \@ "MMMM d, yyyy" }

Here, { MERGEFIELD student-dob } is the Word Fields, and \@ "MMMM d, yyyy" is the MS Word Field Codes that formats the date.

By using MS Word Field Codes, users can:

  • Automatically format text, dates, and currency values when merging documents

  • Perform basic calculations within a document to dynamically display results

  • Apply conditional logic to show different content based on specific data conditions

Considerations for Microsoft Word Field Codes

  • Since Word Document Templates are built using MS Word’s native features, they do not support Template Helpers, except in Grid Tables, which are exclusive to HTML-based templates. To achieve dynamic content generation within Word Document Templates, users have to utilize MS Word Field Codes which act as Template Helper in HTML-based templates for formatting, calculations, and conditional logic.

  • MS Word Field Codes are a built-in Microsoft Word feature and are not provided by eBECAS/EDMISS NextGen.

  • They only apply to Word Document Template and are not available in HTML-based templates.

  • They can only be used for Single Bookmarks. Grid Bookmarks in Grid Tables can utilize Template Helpers in Word Document Template.

  • Before proceeding, it is recommended to familiarize yourself with Creating a Template from a Word File.

Format

Date

To display date type data in different formats, the @ format switch in MS Word Field Codes can be used.

  • Syntax

    • { MERGEFIELD ReplaceWithFieldApiName \@ "DateFormat" }

    • For more details of available date formatting, visit here.

  • Example

    • { MERGEFIELD students-dob \@ "dd/MM/yyyy" } → 21/01/2025

    • { MERGEFIELD students-dob \@ "d MMMM yyyy" } → 21 January 2025

Currency

By default, amounts retrieved from the database are plain numbers, lacking currency symbols, thousand separators, and decimal points. Simply adding a currency symbol manually does not resolve the formatting issues. To ensure proper display, the # format switch in MS Word Field Codes can be used.

  • Syntax

  • Example

    • { MERGEFIELD offers-offer_amount } → 12500.0

    • { MERGEFIELD offers-offer_amount \# "$,##0.00" } → $12,500.00

    • { MERGEFIELD offers-offer_amount \# "€#,##0.00" } → €12.500,50

    • { MERGEFIELD offers-offer_amount \# "# ##0,00" } € → 12 500,50 €

Formula

MS Word Field Codes allow basic arithmetic operations to be performed using MERGEFIELD.

  • Syntax

    • { = { MERGEFIELD ReplaceWithFieldApiName1 } (Operator) { MERGEFIELD ReplaceWithFieldApiName2 } }

MERGEFIELD must be inserted using CTRL + F9, rather than manually typing {} braces.

  • Operators

    • +: Addition

    • -: Subtraction

    • *: Multiplication

    • /: Division

  • Example

    • { MERGEFIELD offers-accommodation_amount } → 5000.0

    • { MERGEFIELD offers-arrangement_amount } → 150.0

    • { = { MERGEFIELD offers-accommodation_amount } + { MERGEFIELD offers-arrangement_amount } } → 5150.0

    • { = { MERGEFIELD offers-accommodation_amount } + { MERGEFIELD offers-arrangement_amount } \# "$,##0.00"} → $5,150.00

Conditional

MS Word Field Codes support conditional logic to display different values based on field comparisons.

  • Syntax

    • { IF { MERGEFIELD ReplaceWithFieldApiName } (Operator) "ComparisonValue" “ValueIfTrue" "ValueIfFalse" }

    • { MERGEFIELD ReplaceWithFieldApiName } is retrieved and the value is compared using the specified ComparisonValue.

    • If true, ValueIfTrue is displayed.

    • Otherwise, ValueIfFalse is displayed.

MERGEFIELD must be inserted using CTRL + F9, rather than manually typing {} braces.

  • Operators

    • =: Equals to ComparisonValue

    • <>: Not equals to ComparisonValue

    • >: Greater than ComparisonValue

    • <: Less than ComparisonValue

  • Example

    • { MERGEFIELD students-first_name } → Ryan

    • { IF { MERGEFIELD students-first_name } = "Ryan" “His name is Ryan" "His name is not Ryan" } → His name is Ryan

    • { IF { MERGEFIELD students-first_name } <> "Ryan" “His name is Ryan" "His name is not Ryan" } → His name is not Ryan

Nested Conditions

  • Syntax

    • { IF { MERGEFIELD ReplaceWithFieldApiName } (ComparisonOperator1) "ComparisonValue1" “ValueIfTrue1" { IF { MERGEFIELD ReplaceWithFieldApiName } (ComparisonOperator2) "ComparisonValue2" “ValueIfTrue2" "ValueIfFalse" } }

    • If { MERGEFIELD ReplaceWithFieldApiName } meets ComparisonValue1 based on ComparisonOperator1, then ValueIfTrue1 is displayed.

    • If not, the second condition is checked. If { MERGEFIELD ReplaceWithFieldApiName } meets ComparisonValue2 based on ComparisonOperator2, then ValueIfTrue2 is displayed.

    • Otherwise, ValueIfFalse is displayed.

MERGEFIELD and nested conditions must be inserted using CTRL + F9, rather than manually typing {} braces.

  • Example

    • { MERGEFIELD offer-location } → Brisbane

    • { IF { MERGEFIELD offer-location } = "Gold Coast" "Classes start at 9:00 AM." { IF { MERGEFIELD offer-location } = "Ipswich" "Classes start at 9:30 AM." "Classes start at 10:00 AM." } } → Classes start at 10:00AM.

Images

Standard MERGEFIELD fields do not support images stored in eBECAS/EDMISS NextGen.
To insert images dynamically, use a special image field format.

  • Syntax

    • { MERGEFIELD "ReplaceWithImageFieldApiName IMAGE |PixelWidth|" }

    • Retrieves the image field data through ReplaceWithImageFieldApiName and set the image size through PixelWidth.

  • Example

    • { MERGEFIELD "students-student_photo IMAGE" } → Insert the Student Photo in the original size.

    • { MERGEFIELD "students-student_photo IMAGE 100" } → Insert the Student Photo in the 100px width size.

QR Codes

By using the QRCODE option, you can dynamically generate and insert a QR code into your Word template from the value of a specified field.

  • Syntax

    • { MERGEFIELD "ReplaceWithImageFieldApiName QRCODE Size" }

    • The size must be specified using WS, WM, WL, or WXL.

  • Advanced Options: For more control, you can specify the exact width size and DPI (Dots Per Inch).

    • { MERGEFIELD "ReplaceWithImageFieldApiName QRCODE WidthSize CustomDpi" }

    • WidthSize: Desired width size of the QR code image.

    • CustomDpi: Print resolution of the QR code image.

  • Example

    • { MERGEFIELD "agents-www QRCODE WM" }

    • { MERGEFIELD "agents-www QRCODE 300 600" }

Barcodes

By using the BARCODE option, you can dynamically generate and insert a barcode into your Word template from the value of a specified field.

  • Syntax

    • { MERGEFIELD "ReplaceWithImageFieldApiName BARCODE |Size|" }

    • Use S, M, L, or XL to specify the barcode width.

    • If the size is omitted, the barcode is inserted using the default M size.

  • Advanced Options: You can specify the exact width size and DPI (Dots Per Inch), and optionally choose whether to display the HRI (Human-Readable Interpretation, the text displayed below the barcode symbol).

    • { MERGEFIELD "ReplaceWithImageFieldApiName BARCODE WidthSize CustomDpi ShowHRI" }

    • WidthSize: Desired width of the barcode image.

    • CustomDpi: Print resolution of the barcode image.

    • ShowHRI: Set true to determine whether the barcode value is displayed below the generated barcode.

  • Example

    • { MERGEFIELD "students-student_id BARCODE" }

    • { MERGEFIELD "students-student_id BARCODE XL" }

    • { MERGEFIELD "students-student_id BARCODE 300 600 true" }

You can dynamically generate and insert Hyperlinks into your Word template from the value of a specified field using the MS Word hyperlink field.

  • Syntax

    • { HYPERLINK { MERGEFIELD ReplaceWithFieldApiName } "OptionalTextForLink" }

    • If OptionalTextForLink is not specified, the URL value itself from the inserted field will be displayed as the link to click.

MERGEFIELD inserted in HYPERLINK must be inserted using CTRL + F9, rather than manually typing {} braces.

  • Example

    • { HYPERLINK { MERGEFIELD agents-www }}

    • { HYPERLINK { MERGEFIELD flywire_payment_requests-request_url } "Click Here to Pay" }

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.