EAWordTemplate
This document was generated using Claude.ai
Overview
Processes Microsoft Word document templates by replacing placeholders with entity data. Reads a template document, substitutes template variables with actual values, handles table loops for detail collections, and generates a final document with entity-specific content.
When This Action Runs
Manual execution for generating entity-specific documents like invoices, contracts, reports, certificates, or any Word document that needs dynamic content based on entity data.
How It Works
- Reads template - Loads Word document from entity flow attachment or specified field
- Processes placeholders - Finds and replaces template variables in format
@#fieldName#@ - Handles table loops - Processes repeating sections for detail collections (invoiceLines, etc.)
- Drops empty loop rows - Removes table rows that a loop produced but that rendered no text
- Replaces image markers - Inserts images from binary fields using
image(fieldName)syntax - Generates document - Creates final Word document with populated data
- Applies protection - Optionally makes document read-only with password protection
- Saves result - Stores generated document in specified attachment field
Parameters
Parameter 1: Save To Field (Required) - Target attachment field to save generated document (e.g., "attachment", "generatedDoc")
Parameter 2: Read Attachment From Field (Optional) - Source field for template document (e.g., "customer.remarks")
Parameter 3: Do Not Make Document Read-Only (Optional) - "true" to keep document editable, "false" for read-only (default: false)
Parameter 4: Generated File Name Tempo (Optional) - Template for output filename using entity data
Parameter 5: Keep Empty Loop Rows (Optional) - "true" to keep table rows whose loop iteration rendered nothing, "false" or empty to remove them (default: false, meaning empty rows are removed)
Template Syntax
Basic Field Replacement
@#fieldName#@
@#customer.name1#@
@#valueDate#@
@#moeny.netValue#@Filtering Loop Rows
A loop inside a table cell produces one table row per detail line. When a condition inside the loop is not met, that iteration renders no text, and the row it produced is removed from the table instead of being left blank:
@#{loop(details)}{if=(details.item.item.section.code, "AP")}{details.item.code}{endif}{endloop}#@Only the lines whose section code is AP appear in the printed table. The rows for the other lines are deleted, so the table has no blank gaps and no extra pages.
A row is removed only when every looping cell of that row rendered nothing for that iteration. If any cell in the row produced text, the row is kept, so cells stay aligned with each other. Whitespace-only output (including non-breaking spaces) counts as nothing.
To keep the old behaviour and print the blank rows, set Parameter 5 to true.
Numbering the remaining rows
{@rownumber} prints the position of the detail line in the collection, so after filtering it shows gaps (7, 12, 30). To number the printed rows sequentially, use a counter that is only incremented for the lines that pass the condition:
@#{loop(details)}{if=(details.item.item.section.code, "AP")}{incrementcounter(sn)}{countervalue(sn)}{endif}{endloop}#@This prints 1, 2, 3, ... over the rows that survive the filter.
Image Insertion
Insert images from binary/attachment fields into the document:
image(fieldName)
image(customer.logo)
image(productImage)The system will:
- Extract the image data from the specified field (must be a LargeData/attachment field)
- Replace the marker with the actual image in the document
- Automatically detect image format (PNG, JPEG, GIF, BMP, TIFF)
- Size the image to 100x100 EMU (default size)
Image Field Requirements
The field referenced in image(fieldName) must be a binary/attachment field containing image data. Supported formats: PNG, JPEG, GIF, BMP, TIFF.
Module: core
Full Class Name: com.namasoft.infor.domainbase.util.actions.EAWordTemplate