5.3 KiB
5.3 KiB
FILL
Populates a document template with data from variables or objects.
Syntax
result = FILL template, data
FILL template, data TO output_path
Parameters
| Parameter | Type | Description |
|---|---|---|
template |
String | Path to template file (Word, Excel, PDF, or text) |
data |
Object | Key-value pairs for placeholder replacement |
output_path |
String | Optional destination path for filled document |
Description
FILL replaces placeholders in document templates with actual data values. Placeholders use double curly braces like {{name}} or {{company}}. This is useful for generating personalized documents, contracts, invoices, and reports.
Examples
Basic Template Fill
data = #{
name: "John Smith",
company: "Acme Corp",
date: FORMAT(TODAY(), "MMMM d, yyyy")
}
result = FILL "templates/contract.docx", data
TALK "Document generated: " + result.path
Invoice Generation
invoice_data = #{
invoice_number: "INV-2025-001",
customer_name: customer.name,
customer_email: customer.email,
items: order_items,
subtotal: subtotal,
tax: tax_amount,
total: total_amount,
due_date: FORMAT(DATEADD("day", 30, TODAY()), "yyyy-MM-dd")
}
FILL "templates/invoice.docx", invoice_data TO "invoices/INV-2025-001.docx"
TALK "Invoice generated and saved"
Certificate Generation
certificate = #{
recipient: participant.name,
course: "AI Fundamentals",
completion_date: FORMAT(TODAY(), "MMMM d, yyyy"),
instructor: "Dr. Sarah Johnson",
certificate_id: GUID()
}
FILL "templates/certificate.docx", certificate TO "certificates/" + certificate.certificate_id + ".docx"
Email Template
email_data = #{
first_name: user.first_name,
order_id: order.id,
tracking_number: shipment.tracking,
delivery_date: shipment.estimated_delivery
}
body = FILL "templates/shipping-notification.txt", email_data
SEND MAIL user.email, "Your order has shipped!", body
Supported Template Formats
| Format | Extension | Placeholder Style |
|---|---|---|
| Word | .docx |
{{placeholder}} |
| Excel | .xlsx |
{{placeholder}} |
| Text | .txt |
{{placeholder}} |
| HTML | .html |
{{placeholder}} |
| Markdown | .md |
{{placeholder}} |
Return Value
Returns an object containing:
| Property | Description |
|---|---|
path |
Path to the generated document |
content |
Document content (for text formats) |
size |
File size in bytes |
Sample Conversation
Generate a contract for Acme Corp
11:15
I'll create the contract. What's the contact person's name?
11:15
Jane Wilson
11:15
✅ Contract generated!
📄 Service Agreement
• Company: Acme Corp
• Contact: Jane Wilson
• Date: May 15, 2025
The contract has been saved to your Drive.
Would you like me to email it to Jane?
11:15
Template Example
A template file might look like:
SERVICE AGREEMENT
This agreement is entered into on {{date}} between:
Company: {{company_name}}
Contact: {{contact_name}}
Email: {{contact_email}}
SERVICES:
{{service_description}}
TERMS:
Duration: {{duration}} months
Payment: ${{monthly_amount}} per month
Start Date: {{start_date}}
Signature: _____________________
Advanced: Lists and Tables
For repeating data, use array placeholders:
data = #{
customer: "Acme Corp",
items: [
#{name: "Widget", qty: 10, price: 29.99},
#{name: "Gadget", qty: 5, price: 49.99}
],
total: 549.85
}
FILL "templates/order.docx", data TO "orders/order-123.docx"
In the template, use {{#items}}...{{/items}} for loops.
See Also
- GENERATE PDF - Convert filled documents to PDF
- MERGE PDF - Combine multiple documents
- UPLOAD - Upload generated documents
- SEND MAIL - Email generated documents