Salesforce Document Generation Guide

Summarize and analyze this article with:

Patricia Vaz Content Writer | Published: (Updated: )

1. Architecture & System Overview

The EDocGen Salesforce Managed Package simplifies document automation by eliminating custom multipart HTTP requests, polling mechanisms, and complex OAuth authentication flows[cite: 4].

Key Architecture Features:

  • Secure Authentication: Managed via Salesforce Named Credentials linked to your EDocGen backend[cite: 4].
  • Asynchronous Execution: Apex invocations spin off background processing to handle heavy document loads without hitting governor limits[cite: 4].
  • Multi-Format Engine: Supports dynamic generation of PDF, DOCX, and PPTX documents from unified templates[cite: 4].
  • Automated Linking: Output files are automatically saved to Salesforce ContentVersion / Files and attached directly to target record IDs[cite: 4].

2. Quick Setup Checklist

  1. Install Package: Deploy the EDocGen Managed Package (namespace: edocgen) into your Sandbox or Production org[cite: 4].
  2. Configure Named Credential & App Settings: In the EDocGen Configuration tab, set your Named Credential, Apex Success Callback, and notification email addresses[cite: 5].
    EDocGen Configuration Page
    Figure 1: EDocGen Configuration tab showing Named Credential and Callback setup[cite: 5].
  3. Update Connection Credentials: Edit the configuration whenever switching environments or updating Named Credentials[cite: 5].
    Updating Named Credential Configuration
    Figure 2: Updating the active Named Credential binding in Salesforce Admin settings[cite: 5].
Need detailed setup steps? See the step-by-step Post-Install Configuration Guide[cite: 4, 5].

3. UI Integration Strategies

EDocGen supports single-record generation actions, list view bulk processing, and Apex-driven automation[cite: 4].

Record Action

Single Record Page

Bind the edocgen:Templates Lightning Component to a custom Action button on any standard or custom object page layout[cite: 4].

List View

Bulk List Button

Add a standard List Button targeting the packaged Flow URL /flow/edocgen/EDocGen to process multiple selected records[cite: 4, 5].

Automation

Apex & Flow API

Trigger background generation logic via Apex code, Scheduled Jobs, or Salesforce Invocable Actions[cite: 4].

Setting Up Single Record Actions

To add a document generation button to a record page (e.g., Order or Opportunity):

  1. Go to Object Manager > [Object] > Buttons, Links, and Actions and click New Action.
  2. Select Lightning Component as the Action Type, choose edocgen:Templates, and assign a label like Generate Document[cite: 5].
  3. Add the new action to the Salesforce Mobile and Lightning Experience Actions section of your Page Layout.
  4. Users can now generate documents directly from the record action bar[cite: 5].
    Generate Document Action on Record Detail Page
    Figure 3: The active Generate Document button on a record page[cite: 5].
  5. Select your template from the dialog to generate the output file[cite: 5].
    Template Selection Dialog
    Figure 4: Template selection dialog on a record[cite: 5].

Setting Up Bulk List View Actions

To enable multi-record generation from list views:

  1. In Object Manager under Buttons, Links, and Actions, click New Button or Link.
  2. Set Display Type to List Button and target the packaged URL /flow/edocgen/EDocGen[cite: 5].
    Generate Documents List Button
    Figure 5: Generate Documents list button on a list view[cite: 5].
  3. Follow the guided flow to process batch outputs[cite: 5].
    Bulk Generation Flow
    Figure 6: Bulk generation flow initiated from a list view[cite: 5].

Output Attachment & Template Management

Manage your document templates and access generated files directly inside Salesforce[cite: 5]:

EDocGen Templates in Salesforce
Figure 7: EDocGen Templates management in Salesforce[cite: 5].
Generated Document Output in Salesforce Files
Figure 8: Example generated PDF or DOCX file linked under Files[cite: 5].

Common Implementation Targets

Object Domain Output Documents Recommended Pattern
Opportunity / Quote Proposals, Master Service Agreements Single Record Action (Lightning Component)[cite: 4]
Order / Account Invoices, Statements, Account Summaries Apex Trigger or Scheduled Batch Job[cite: 4]
Contact / Case Batch Letters, Work Order Summaries List View Bulk Action Flow[cite: 4]

4. Apex API Reference

Execute document generation programmatically from Apex using the global entry point method[cite: 4]:

edocgen.EdocGenDocumentGeneration.generateDocuments(wrapper)[cite: 4]

Example: Single & Bulk Code Invocation

// Initialize wrapper with target Template ID and Record IDs
List<Id> recordIds = new List<Id>{ '001XXXXXXXXXXXX', '001YYYYYYYYYYYY' };
Id templateId = 'a0BXXXXXXXXXXXX'; // edocgen__EDocGen_Templates__c ID

edocgen.EdocGenDocumentGeneration.DocumentGenerationWrapper wrapper =
    new edocgen.EdocGenDocumentGeneration.DocumentGenerationWrapper(
        templateId,            // EDocGen Template ID or Name String
        recordIds,             // Single or multiple Record IDs
        null,                  // Org-Wide Email Address ID (Optional)
        'BillingAddress',      // To Address field API path (Optional)
        'Contact.Email',       // CC field API path (Optional)
        null                   // BCC field API path (Optional)
    );

// Trigger generation asynchronously
edocgen.EdocGenDocumentGeneration.generateDocuments(wrapper);

For extensive signature options and parameter details, reference the full Apex Quickstart Guide[cite: 4].

5. Template Data Mapping

Templates are configured using familiar Office tags (e.g., {Account_Name}, {Total_Amount}) and synced to Salesforce via the EDocGen Templates (edocgen__EDocGen_Templates__c) object[cite: 4, 5].

  • Cross-Object Mapping: Traverses parent and child relationships configured within the template[cite: 4].
  • Automated Delivery: Configure post-generation email dispatching including dynamic subject, body, and recipient fields[cite: 4, 5].
  • Activity Tracking: Automatically records completed generation tasks under target Salesforce Activity Timelines[cite: 4, 5].

6. Callbacks & Failure Notifications

Asynchronous Success Callback

To handle post-generation workflows (such as updating record status fields), implement the edocgen.ConnectorToOrg.ConnectorInterface[cite: 4]:

global class EDocGen_SuccessCallBack implements edocgen.ConnectorToOrg.ConnectorInterface {
    global void handleDocumentGenerateSuccess(Map<String, String> generateSuccessMap) {
        // Retrieve JSON mapping: RecordId -> ContentVersionId
        String recordToContentMapJson = generateSuccessMap.get('recordIdWithContentVersionIdMap');
        
        // Execute post-generation business logic
        System.debug('Generation output details: ' + generateSuccessMap);
    }
}

Admin Email Alerts

Configure comma-separated admin email addresses in the EDocGen Configuration Tab to instantly receive notifications if document rendering or file upload failures occur[cite: 4, 5].

Install on AppExchange Post-Install Guide Apex Reference Guide

Frequently Asked Questions

How does EDocGen generate documents in Salesforce?

EDocGen uses reusable document templates containing merge fields that map to Salesforce objects such as Accounts, Opportunities, and Contacts. When a user clicks a generate button on a record, the app pulls the current field values, fills the template, and produces a finished document. The output can be saved to the record, attached as a file, or sent to recipients without leaving Salesforce.

What file formats does EDocGen support?

EDocGen supports common business document formats, including PDF for sharing and archiving and editable Word (DOCX) files for review and revision. Templates are stored within Salesforce and can produce outputs in the formats your organization needs. For the complete and current list of supported output types, check the product documentation or ask your Salesforce administrator.

Can EDocGen create documents for many records at once?

Yes. Users can select multiple records from a Salesforce list view or report and generate documents for all of them in one batch. Each document is personalized with the data from its own record, and the generated files are saved back to the corresponding records. Large batches run in the background, so users can continue working while processing completes.

How does EDocGen merge CRM data into documents?

EDocGen reads field values directly from Salesforce, including standard objects like Accounts and Contacts as well as custom objects. It can also populate tables with related child records, such as opportunity line items. Data is pulled at the time of generation, so documents reflect the latest CRM information, and access to sensitive fields follows your existing Salesforce permissions.

Related Developer Documentation