Thanksgiving Week Special – Get 50% OFF on FileTranz

Claim Your Offer

OmniStudio Document Generation with Omni Data Transform

Discover how to generate documents with dynamic Salesforce data using OmniStudio from template design to final UI execution

By Jothish Bahuleyan
Software Developer

OmniStudio Document Generation with Omni Data Transform: A Complete Server-Side Implementation Guide

 

Documents play an important role in every business across the entire business lifecycle - from generating quotes and proposals to creating the contract, order documents, and compliance reports. As businesses develop and become more complex, organizations often need documents with dynamic data, reusable templates, conditional content, tables, images, and consistent branding. Traditionally, generating highly customized documents from Salesforce often required third-party solutions or significant custom development. With the help of OmniStudio Document Generation, Salesforce provides a native, low-code approach that allows organizations to generate professional, data-driven documents directly from Salesforce. In this blog, we are going to explore, how to implement server-side document generation using Omni Data Transform, using Quote document generation as an example. This blog consists of complete walkthrough - from creating the template using MS Word and extracting the Salesforce data and transforming that data, configuring OmniScript, and generating the final document from Salesforce UI.

Prerequisites

Before stepping into OmniStudio Document Generation, ensure the following setup is completed to have the OmniStudio components and permissions in your Salesforce org.

Salesforce Setup

  • Salesforce org must have the Omnistudio package installed.

Required Permission Sets

  • OmniStudio Admin: Grants admins and developers the ability to create new OmniScripts, Data Mappers, FlexCards, and Integration Procedures instances. This permission set license also provides calculation runtime access.

  • OmniStudio User: Grants users permission to execute OmniScripts, Data Mappers, FlexCards, and Integration Procedures. This permission set also provides calculation runtime access.

  • DocGen Designer: Enables designers to create document templates and generate documents.

  • DocGen User: Allows end users to generate documents using existing templates.

Document Generation Workflow

Before getting into the configuration, it's useful to understand how the different OmniStudio components work together during document generation. The overall workflow consists of the stages mentioned in the diagram below.

 

OmniStudio Document Generation Workflow
 

Steps to Implement Document Generation

Step 1: Define Document Template:

The first step of the OmniStudio Document Generation is to create your document in Microsoft Word or a PowerPoint template. The template includes placeholders (tokens) that are replaced with Salesforce data during document generation, along with formatted text, tables of contents, paragraphs, images, etc. For this example, we’ll use a Microsoft Word document as the template. The template can contain static content as well as dynamic placeholders, allowing Salesforce data to be inserted at runtime.

Note: Placeholders should be enclosed in double curly brackets {{tokenName}}. Example: {{QuoteNumber}}. The token names must align with the output produced by the Transform Data Mapper.
 

Sample Quote Document Template

 

Step 2: Design Document Template

Once we designed the Word or PowerPoint document template, the next step is to configure it in Salesforce using Document Template Designer. Below are the steps,

  • In the App Launcher, search for Document Template Designer, select it, and create a new template.
  • Configure the template details:

    • Name: Enter the document template name (avoid spaces).
    • Template Type: Choose the type of document you are going to upload (Word or PowerPoint).
    • Token Mapping: Default JSON.
    • Token Mapping Method: Select Omni DataTransform.This defines how Salesforce fields will replace the placeholders.
    • Mapping DataMapper Bundle Name: Enter your Data Mapper Transform name. If not already created, you can enter a name, and Salesforce will create it in the backend.
    • Data Extract DataMapper Bundle Name: Enter your Data Extract Mapper name. If not already created, you can enter a name, and Salesforce will create it in the backend.
    • Usage Type: Choose the usage type based on your business scenario.
      • Revenue Lifecycle Management – Quote and Order documents.
      • Contract Lifecycle Management – Contract documents
    • Document Generation Mechanism: Select how the document will be generated:
      • Client‑side – The DataMapper bundle runs directly in the browser/session.
      • Server‑side – The call to Omni Data Transform is handled on the server instead.
         

    Note: In this blog, we'll use the Server-Side document generation mechanism with Omni Data Transform, which is the recommended standard approach for most implementations.

  • Finally, upload the Microsoft Word or PowerPoint template created in Step 1, then click Save and Activate the Design Document Template.


 
Document Template Designer - Omnistudio


Step 3: Configure Data Mappers

Data Mappers determine how Salesforce data is retrieved and structured for document generation. For this example, we'll configure two Data Mappers:

  • Data Mapper Extract: This retrieves the required Quote and Quote Line Items data from Salesforce.
  • Data Mapper Transform: Converts the extracted data into the token structure expected by the document template.

Configure Data Mapper Extract

  • Open Data Mapper Extract
    • In the App Launcher, search for Data Mappers, select it, and open the Data Mapper Extract that you named during Design Document Template creation.
    • Go to the Extract tab, click the (+) button and select the object that you want to query, along with any filter conditions and parent child (related object) hierarchy needed. For this blog, we need to query Quote along with its line items.
  • Configure Quote Extraction
    • Extraction Object: Quote (Select the object name to query).
    • Extraction Object Path: quote (top level JSON node that will hold the extracted data).
    • Field: Id (Field name used in filter condition).
    • Operator: Equals (Logical operator for the filter).
    • Value: Id (Record ID value passed in at runtime).
  • Configure Quote Line Items.
    Link Quote Line Items to the parent Quote so only related records are fetched.
    • Extraction Object: QuoteLineItem
    • Extraction Object Path: quote:quoteLineItem
    • Field: QuoteId
    • Operator: Equals
    • Value: quote:Id

This ensures that only the relevant Line Items for the specified Quote are extracted. You can also configure Offset, Order By, and AND/OR conditions here for more advanced filtering needs. Refer to this guide if you want to learn more on Data Mappers.

 

Data Mapper Screen

 

  • Map Data Fields: Once the Extract is configured, the next step is to map the fields so that the data flows correctly into your document template.
    • Navigate to the Mapping tab. In the Mapped Fields container, click Create Mapping.
    • Extract JSON Path – Select the field from the Extract JSON that you want to return.
    • JSON Output Path – Define the variable path where the Extract JSON data will be stored.
    • Click Add or Save & New to continue mapping additional fields.
    • Activate it.

       

      Data Mapper Screen

 

  • Preview Data Mapper: After creating the mapping fields, use the Preview option to verify that the data is correctly extracted.

    • Click the Preview button in the top right.
    • Add input parameter:
      • Key: Id
      • Value: 0Q0XXXXXXXXXXXXXXX (replace your quote record ID)
    • Execute the preview.
    • The extracted data will appear in the Response screen, showing the JSON output.

       

      Data Mapper Preview

     

Configure Data Mapper Transform

The Transform step converts the extracted Salesforce data into tokenized values that match the placeholders in your document template.

  • From the Data Mapper, open the Data Mapper Transform that you named during Design Document Template creation.
  • Make sure the Data Mapper Settings match the configuration.
  • Go to Transforms tab, click Create Mapping in the Mapped Fields container.
    • JSON Input Path – Select the JSON input field to return.
      Tip: Copy the preview response from the Data Mapper Extract and paste it into Edit Input JSON (via the Manage Input/Output Type action button).
    • Output Document Template Path – Define the variable that stores the JSON input path value.
      This must match the token name used in your document template.
  • Activate it.

     

    Data Transform Screen

     

  • Preview Data Mapper Transform
    • Click the Preview button in the top right.
    • In Input Parameters, you’ll see the JSON data you pasted into the Edit Input JSON.
    • Execute the preview.
    • Confirm that the Response screen shows the transformed JSON output, with keys matching the tokens in your document template.

       

      Data Transform Preview


Step 4: Configure Omniscript

The OmniScript acts as the orchestration layer. It receives the current Quote Record ID, passes that ID to the document-generation component, and initiates the server-side document generation process.  Lets configure the OmniScript by following the steps below,

  • In the App Launcher, search for OmniScript and open the Single Doc Core – DOCX Serverside (LWC) and create a new version.
  • From the Elements panel, drag and drop a Set Values standard action to the top of the designer.
  • Select the element and configure the Set Values Properties:
    • Name: SVFetch_ObjectRecordId
    • Find Label: Fetch Object RecordId
    • Element Value Map:
      • Element Name: RecordID
      • Value: %ContextId%
  • Click Save.
  • In the Select Template Type & Template Step, remove the RecordIdTemplateType step properties and activate the designer.
  • In the Generate Document Step, click the Custom LWC element.
    • Expand the Custom Lightning Web Component Properties section.
    • Update the context‑id mapping:
      • Property Name: context-id
      • Property Source: %ContextId%
    • This ensures the RecordId is dynamically passed from the record page into the OmniScript.
  • Use the Preview option to verify that the %ContextId% value is correctly populated and passed through the OmniScript.

     

    OmniScript Configuration

 

Step 5: Configure Record Page

To enable document generation from the Quote record page, you need to add the OmniScript component in the Lightning App Builder.

  • Open Lightning App Builder
      Access the page editor from the Quote record page.
    • From the Quote record, click the gear icon on the top right and select Edit Page. This redirects you to the Lightning App Builder.
       
  • Add Document Tab
    • In the Tabs component, click Add Tab and set the Tab Label to Document.
    • This creates a new tab section for the OmniScript component.
       
  • Place OmniScript Component
    • Use the left‑side search input to find OmniScript and drag the OmniScript component into the Document Tab
    • Position it where you want the document generation UI to appear and select docGenerationSample as the component type.



Salesforce Quote Record Page


Step 6: Test Document Generation

  • Navigate to the Quote record page and go to the Document tab where you placed the OmniScript component.
  • Provide the required Input Parameters and verify that the document is generated with Salesforce data correctly merged into the placeholders.

This completes the end-to-end implementation of server-side OmniStudio Document Generation using Omni Data Transform.

Quote Document

Conclusion

We’ve now walked through the full journey of Server‑side Document Generation with Omni Data Transform starting from template design, configuring Data Mappers, mapping fields, setting up OmniScript, and finally testing it all in the Salesforce UI. This approach isn’t just the “standard” way; it’s the reliable way to make sure your documents are generated consistently and at scale, without hiccups. Think of it as laying a strong foundation for any future enhancements you’ll build on top. And this is just the beginning. In the next blog, we’ll take things a step further by exploring Document Generation with Integration Procedure and Server‑side Token Data, giving you even more flexibility and control in complex scenarios. Turn Salesforce data into dynamic documents with ease!


free-consultation