# Vlocity Document Generation

Step 1: Create Dataraptor Post and Dataraptor Transform for the source of data for the document.

***Note:** For DR extract always just use 1 dynamic variable "Id" in filter condition*

Step 2: Create a word Document with merge fields ([Reference](https://help.salesforce.com/s/articleView?id=ind.v_contracts_tokens_in_microsoft_word_or_microsoft_powerpoint_documents.htm\&type=5))

Step 3: Create Document Template (vlocity\_cmt\_\_DocumentTemplate) and configure document type

Step 4: Create OmniScript and DR to extract Document details something like given below

```
{
  "DocumentTemplate": {
    "DocumentGenerationMechanism": "VlocityClientSide",
    "Active": true,
    "TemplateType": "Microsoft Word .DOCX Template",
    "Name": "Seacom Quote Document",
    "Id": "a6DHu0000019SPTMA2"
  }
}
```

Step 5: In OS Step use LWC component that ends like "**OsDocxGenerateDocument**" , it can be differemt for org depending upon industry

```
{
  "customAttributes": [
    {
      "name": "context-id",
      "source": "%QuoteId%"
    },
    {
      "name": "selected-template",
      "source": "%selectedTemplate%"
    },
    {
      "name": "debug",
      "source": "false"
    },
    {
      "name": "document-title",
      "source": "%documentTitle%"
    }
  ]
}
```

For selectedTemplate<br>

```
"selectedTemplate": {
      "Name": "%DocumentTemplate:Name%",
      "VersionNumber": 1,
      "DocumentGenerationMechanism": "VlocityClientSide",
      "TemplateType": "%DocumentTemplate:TemplateType%",
      "Id": "%DocumentTemplate:Id%",
      "Select": true
    }
```

Configure the mapping which are obtained from DR extract of Document template before the generate document step


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mubariks-organization.gitbook.io/omnistudio-helper/vlocity-document-generation.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
