document-generation

Create and troubleshoot Salesforce OmniStudio .docx templates and DocumentTemplate lifecycle operations.

Updated Sep 23, 2026
One-click install
npx skills add https://github.com/drgaciw/rlm-base-dev-fork --skill document-generation-drgaciw
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: document-generation
Source: https://github.com/drgaciw/rlm-base-dev-fork/tree/main/.cursor/skills/document-generation
Command: npx skills add https://github.com/drgaciw/rlm-base-dev-fork --skill document-generation-drgaciw

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires python-docx, poppler, and includes scripts (resource) and references (resource) components.

What problem does it solve? Building Salesforce OmniStudio document templates involves strict token syntax, paired Extract/Transform OmniDataTransforms, and lifecycle rules where small mistakes (null OutputObjectName, dot notation, wrong image IDs) silently produce blank output or engine crashes. This Skill encodes the verified contracts, pitfalls, and helper scripts so templates generate correctly the first time. ## Core Features & Use Cases - Template authoring and token mapping: Create or modify .docx templates using scalar, repeating-section, conditional (IF_), image (IMG_), hyperlink (HYP_), and rich-text (RTB_) tokens with exact Transform output shapes. - DocumentTemplate lifecycle management: List, inspect, activate/deactivate, upload binaries, and wire Extract/Transform ODTs via the docgen_template_* scripts, with deactivate-before-edit enforcement. - End-to-end verification: Execute Extracts and Transforms via the OmniStudio REST API and run full DGP generation (Extract → Transform → .docx → PDF) as smoke tests. - Use Case: Add a new field to an invoice template by inserting the token in the .docx, adding matching field mappings to the Extract and Transform ODTs, re-toggling them, replacing the template binary, and generating a test document to confirm output. ## Quick Start Ask the agent to read the document-generation skill and generate a test document from template RLM_QuoteProposal against a quote record in the dev-scratch org.

Frequently Asked Questions about document-generation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create a Salesforce OmniStudio document template with tokens?▼

Create a .docx with mustache tokens ({{FieldName}} for scalars, {{#Section}}...{{/Section}} for repeating rows), then wire a DocumentTemplate record to one Extract and one Transform OmniDataTransform by exact name. Use docgen_template_manage.py create to build and activate the template.

How do I add dynamic images to a Salesforce document template?▼

Place a plain-text {{IMG_name}} token in the .docx and have the Transform output a nested object with src, width, and height. The src must be a ContentDocument ID (069 prefix), not a ContentVersion ID or file title, and all three fields are mandatory.

Why does my OmniStudio document generate blank output?▼

Blank output usually comes from OmniDataTransformItem records with null OutputObjectName, duplicate object query items, or dot notation in InputFieldName instead of colons. Run docgen_odt_validate.py to lint items and docgen_odt_execute.py to inspect actual Extract output.

Can I edit an active DocumentTemplate in Salesforce?▼

No. You must set the DocumentTemplate to Draft (IsActive false) before replacing the binary or changing fields like TargetOutputFileName or MapperOmniDataTransformName, then reactivate after edits. The docgen_template_manage.py replace command automates this lifecycle.

Should I use the REST API or Metadata API to manage OmniDataTransforms?▼

Use Metadata API XML (.rpt-meta.xml) deployed via the prepare_docgen flow for committed and production work. The SObject REST API is officially internal-use-only and appropriate only for scratch-org debugging, cloning, and rapid iteration.

Why does my IF_ conditional token always render in the template?▼

IF_ tokens accept Boolean values only; strings and numbers always evaluate as true. Use an IF(expression, true, false) formula in the Transform ODT so the output is a real Boolean.