---
schema_version: "1"
id: ed008e6aa67cfd0cd5dfbee690d9897ad37aa58a7e089ce69c8353c7bd1f0699
title: Create a Document Generation Process Record Using Flow or Apex
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/ind/264-0-0/billing_invoice_document_generation_process_record.md
canonical_url: https://help.salesforce.com/s/articleView?id=ind.billing_invoice_document_generation_process_record.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: efa24e0062bcd504282f4eea070a9933c530f698efb109384074f93f574f5d35
description: Create a Document Generation Process record by creating a Flow with a Create Records element or by configuring an Apex class.
products:
  - Revenue Cloud
release: "264"
---
# Create a Document Generation Process Record Using Flow or Apex

Create a Document Generation Process record by creating a Flow with a Create Records element or by configuring an Apex class.

### Required Editions

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small edition"><colgroup><col></colgroup><tbody><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: Lightning Experience</td></tr><tr class=""><td class="slds-cell-wrap" style="vertical-align:top;">Available in: <strong>Enterprise</strong>, <strong>Unlimited</strong>, and <strong>Developer</strong> Editions with <a href="https://help.salesforce.com/s/articleView?id=ind.revenue_licenses_areas_and_features.htm&amp;release=264.0.0&amp;type=5">the Revenue Cloud Billing license</a>. Contact your Salesforce account executive for more information.</td></tr></tbody></table>

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small permission">
        <colgroup>
          <col style="width:50%">
          <col style="width:50%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="colgroup" class="slds-cell-wrap" colspan="2" style="text-align:center;vertical-align:top;" id="d80143e75">User Permissions
              Needed</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d80143e75 ">To create a flow:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d80143e75 ">Manage Flow</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d80143e75 ">To configure an Apex class:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d80143e75 ">Author Apex</td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d80143e75 ">To create a Document Generation Process record:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d80143e75 ">
              <p>Billing Admin permission set</p>
              <p>OR</p>
              <p style="margin-bottom:0;">Billing Operations User permission
                set</p>
            </td>

          </tr>
          <tr class="">
            <td data-label="User Permissions Needed" class="slds-cell-wrap" style="vertical-align:top;" headers="d80143e75 ">To generate invoice PDF documents:</td>

            <td class="slds-cell-wrap" style="vertical-align:top;" headers="d80143e75 ">DocGen User permission set</td>

          </tr>
        </tbody>
      </table>

If you create a flow, add an element to get the document template to use for generating the invoice PDF document. Then, add a Create Records element with these values:

1. Enter Generate And Convert as the type.
2. Enter Document Template as the document input type.
3. Enter DefaultInvoiceTemplate record Id or any custom document template as the document template.
4. Enter a JSON input in the `{"Id":"<Enter Invoice ID>"}` format as the data mapper input.
5. Enter the ID of the record for which you want generate a PDF document as the reference object.
    
    The generated PDF document is attached to the record.
6. Enter a JSON input in the `{"keepIntermediate":false,"title":"<Enter Invoice Number/ Document Number>"}` format as the request input.
7. Enter Advanced as the doc generation API version type.
8. Enter In Progress as the status.
    
    ![Omniscript Flow](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-ind-revenue-264-0-0-production-enus/91ca99c6-d5c8-4986-b961-c6b7801e0d0d/revenue/images/billing/billing_docgen_flow.png)

If you [configure an Apex class](https://help.salesforce.com/s/articleView?id=ind.doc_gen_sample_apex_code_for_server_side_document_generation.htm&language=en_US), specify the same values that are mentioned for the Create Records element.