document-placeholder-replacer
Service icon

Document Placeholder Replacer

Stable version 1.0.0 (Compatible with OutSystems 11)
Uploaded
 on 1 Feb (yesterday)
 by 
0.0
 (0 ratings)
document-placeholder-replacer

Document Placeholder Replacer

Documentation
1.0.0

Document Placeholder Replacer

Document Placeholder Replacer helps you generate DOCX documents dynamically by replacing placeholders in Word templates with real data at runtime.

It is designed for common business scenarios like contracts, offer letters, invoices, reports, and any situation where a standard Word template needs to be personalized with dynamic values.


How it works

  1. Start with a DOCX template that contains placeholders

  2. Pass the template as Binary Data

  3. Provide a list of key–value pairs

  4. The service replaces all matching placeholders

  5. The updated DOCX is returned as Binary Data

The replacement is safe even when placeholders are split across Word runs or placed inside tables, headers, or footers.


Available Action

ReplacePlaceholders

This action replaces all placeholders in the given DOCX document using the provided key–value pairs.


Input parameters

  • Document
    The DOCX file content as Binary Data.

  • Pairs
    A list of placeholder key–value pairs.

  • PlaceholderFormat
    The placeholder format used in the document.
    Default format is {{KEY}}.


Output parameters

  • UpdatedDocument
    The updated DOCX file returned as Binary Data.


Placeholder structure

Each placeholder pair contains:

  • Key – the placeholder name

  • Value – the text that should replace it




Placeholder format examples

The placeholder format must contain the word KEY.

Common examples:

  • {{KEY}}{{Name}}

  • [[KEY]][[InvoiceNumber]]

  • %KEY%%Date%

If no format is provided, {{KEY}} is used automatically.



Error handling

The action throws clear runtime errors when:

  • The input document is empty or invalid

  • The placeholder list is empty

  • Duplicate placeholder keys are provided

  • The placeholder format does not contain KEY

  • The DOCX file is corrupted

These errors can be handled using standard OutSystems exception handling.


Notes & limitations

  • Only DOCX format is supported

  • Placeholders inside images or charts are not replaced

  • When placeholders span multiple Word runs, formatting may be unified

  • Designed for server-side execution



Typical use cases

  • Contract generation

  • Offer letters

  • Invoices and statements

  • Report generation

  • Workflow-based document automation