---
schema_version: "1"
id: 2ac72e1f85338f9be71c9a0ea79d68cd0f20351cdee4060241439c3d4a0a24c0
title: Create a Custom Generate Document Button
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/doc_gen_create_a_custom_generate_document_button_394436.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.doc_gen_create_a_custom_generate_document_button_394436.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 02dd5fadcc6ccfc7a08a8f83684b9bc4a995cb360c6dd4ff792989e226b27dcc
description: Generate documents from any object such as a contract, order, quote, work order, or opportunity by integrating Omniscript into a custom button. This example uses the fndSingleDocxLwc Omniscript to generate single client-side documents from Microsoft Word .docx or Microsoft PowerPoint .pptx templates.
products:
  - Omnistudio Document Generation
release: "264"
---
# Create a Custom Generate Document Button

Generate documents from any object such as a contract, order, quote, work order, or opportunity by integrating Omniscript into a custom button. This example uses the fndSingleDocxLwc Omniscript to generate single client-side documents from Microsoft Word .docx or Microsoft PowerPoint .pptx templates.

To configure a custom button, perform these steps:

1. Retrieve Lightning URL from the fndSingleDocxLwc Omniscript.
    1. Open the fndSingleDocxLwc Omniscript.
    2. From the Actions dropdown list, click **How to Launch**.
    3. Scroll to Lightning, and then copy the URL starting from `/lightning/cmp/omnistudio`.
        
        ![The How to Launch page with the Lightning URL highlighted.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-document_generation-264-0-0-production-enus/f76d5573-56ce-4576-b4b2-7a4f1f2e622b/document_generation/images/clm234_custom_document_generate_button_01.png)
        
        Here's an example.
        
        ```
        /lightning/cmp/omnistudio__vlocityLWCOmniWrapper?c__target=c:docGenerationSampleFndSingleDocxLwcEnglish&amp;c__layout=lightning&amp;c__tabIcon=custom:custom18
        ```
    4. Click **Done**.
2. Create a custom Generate Document button.
    1. In Setup, click **Object Manager**.
    2. Click the object for which you want to create the custom Generate Document button. For example, Work Order.
    3. Click **Buttons, Links, and Actions**.
    4. Click **New Button or Link**.
    5. Enter these details:
        
        - **Label**: Generate Document
        - **Name**: Generate\_Document
        - **Display Type**: Detail Page Button
        - **Behavior**: Display in new window
        - **Content Source**: URL
        - **Button or Link URL**: Paste the Lightning URL that you copied from the fndSingleDocxLwc Omniscript.
        
        ![The Work Order page.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-document_generation-264-0-0-production-enus/f76d5573-56ce-4576-b4b2-7a4f1f2e622b/document_generation/images/clm234_custom_document_generate_button_02.png)
    6. Save your work, and then click **OK**.
    7. To add the template type as a parameter, enter &c\_\_TemplateType=MicrosoftWord at the end of the URL.
        
        Here's an example.
        
        ```
        /lightning/cmp/omnistudio__vlocityLWCOmniWrapper?c__target=c:docGenerationSampleFndSingleDocxLwcEnglish&c__layout=lightning&c__tabIcon=custom:custom18&c__TemplateType=MicrosoftWord
        ```
    8. To add the Object ID as a parameter, at the end of the URL, enter &c\_\_ObjectId=.
    9. From the Insert Field dropdown list, select the object work ID to add the custom Generate Document button to your object. For example, Work Order ID.
        
        The object work ID parameter is added to the URL.
        
        Here's an example.
        
        ```
        /lightning/cmp/omnistudio__vlocityLWCOmniWrapper?c__target=c:docGenerationSampleFndSingleDocxLwcEnglish&c__layout=lightning&c__tabIcon=custom:custom18&c__TemplateType=MicrosoftWord&c__ObjectId={!WorkOrder.Id}
        ```
        
        ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-document_generation-264-0-0-production-enus/f76d5573-56ce-4576-b4b2-7a4f1f2e622b/images/icon_note.png)
        
        Note During the document generation process the work ID parameter is replaced with an actual work ID.
    10. Save your work.
3. Add the Generate Document custom button to the object.
    1. In Setup, click **Object Manager**.
    2. Click **yourobject** > **Page Layouts** > **yourobjectLayout** > **Buttons**.
        
        For example, **Work Order** > **Page Layouts** > **Work Order Layout** > **Buttons**.
    3. Select **Generate Document**, and then drag it to the Custom Buttons section.
        
        ![The Work Order layout with the Generate Document button highlighted.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-document_generation-264-0-0-production-enus/f76d5573-56ce-4576-b4b2-7a4f1f2e622b/document_generation/images/clm234_custom_document_generate_button_03.png)
        
        The Generate Document custom button is added to the Actions menu.
    4. Save your changes.
        
        You can now directly generate documents from your object by using the Generate Document custom button.
4. Generate the Microsoft Word .docx document.
    1. On your object page, from the Actions dropdown list, click **Generate Document**.
        
        The fndSingleDocxLwc Omniscript is triggered. The Object ID and Template Type fields are populated by default.
        
        ![The Enter Object Id page.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-document_generation-264-0-0-production-enus/f76d5573-56ce-4576-b4b2-7a4f1f2e622b/document_generation/images/clm234_customize_fndsingledocxlwc_omniscript_05.png)
    2. Click **Next**.
    3. Select a template, and then click **Next**.
        
        ![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-document_generation-264-0-0-production-enus/f76d5573-56ce-4576-b4b2-7a4f1f2e622b/images/icon_note.png)
        
        Note
        
        To hide the Pick a template window and to customize the fndSingleDocxLwc Omniscript, see [Customize fndSingleDocxLwc Omniscript](https://help.salesforce.com/s/articleView?id=ind.doc_gen_customize_fndsingledocxlwc_omniscript_394579.htm&release=264.0.0&type=5 "You can customize the fndSingleDocxLwc Omniscript according to your requirements. In this example, customize the Omniscript to set a default template and hide the pick a template window during the document generation process.").
    4. Select the generation options, and then click **Next**.
        
        ![The Generation Options page.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-document_generation-264-0-0-production-enus/f76d5573-56ce-4576-b4b2-7a4f1f2e622b/document_generation/images/clm234_customize_fndsingledocxlwc_omniscript_06.png)
        
        The document is generated.
        
        ![The generated document.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-document_generation-264-0-0-production-enus/f76d5573-56ce-4576-b4b2-7a4f1f2e622b/document_generation/images/clm234_customize_fndsingledocxlwc_omniscript_07.png)
        
        You can download the .pdf and .docx version and attach the appropriate object record or email it.