Project Overview
This project focused on implementing a scalable and extensible document generation framework using Conga Composer for a real estate organization managing shopping malls and commercial buildings. The solution primarily supported post-sales processes, including shop lease contracts, rentals, extensions, and renewals.
The organization previously relied on a mix of DocGen solutions and manual document preparation, which lacked flexibility and required significant effort to maintain. Conga Composer was adopted to enable a more programmable, extensible, and controlled document generation approach using Apex.
Business Context & Technology Transition
Previous State
- Salesforce DocGen was used for limited scenarios but was restrictive when advanced customization was required.
- Several post-sales documents were created manually outside Salesforce.
- Extending or modifying document behavior beyond standard configuration was difficult.
Decision to Use Conga Composer
Conga was selected because it:
- Provided API-based execution (Composer 8 APIs)
- Allowed Apex-driven control beyond UI configuration
- Enabled reuse of a single solution across multiple business processes
Business Challenges
- Multiple document types (contracts, rentals, extensions, renewals) required similar logic but separate configurations.
- Environment-specific values (endpoints, URLs, session handling) needed to vary across orgs.
- Existing approaches required excessive configuration effort for each business scenario.
- No centralized control existed for retry handling, execution flow, or error management.
Solution Architecture Overview
A centralized Apex-driven Conga framework was designed with a clear separation of responsibilities:
- Custom Metadata → Environment and platform-level configuration
- Custom Configuration Object → Business-level Conga document behavior
- Central Conga Object → Execution and orchestration
This separation avoided overloading metadata with business logic while keeping the solution flexible and maintainable.
Custom Metadata for Environment & Platform Configuration
Custom Metadata Types were used only to store values that are:
- Environment-specific
- Org-dependent
- Required for Conga and Salesforce integration
Stored values included:
- Conga ENDPOINT URL
- Salesforce and Conga access endpoints
- Session ID–related parameters
- Remote Site and callout-related configuration values
Key Design Rationale
- Metadata ensures environment portability (Dev, UAT, Prod, multiple orgs).
- No hardcoded URLs or endpoints exist in Apex.
- Endpoint or access changes require metadata updates, not code changes.
Metadata was not used for business-level document logic.
Custom Configuration Object for Conga Solution Behavior
A separate custom configuration object was used to control Conga document generation behavior at the business level.
This object stores:
- Conga template file references
- Output type (PDF, DOCX, etc.)
- File naming rules per template
- Conga query references
- Execution flags (attach to record vs browser download)
Each record represents a business-specific document configuration, allowing different templates under the same Conga Template to behave differently.
This design allowed:
- Fine-grained control per template file
- Easy extension for new document types
- Zero code changes for most business enhancements
Central Conga Execution Object
A single custom object was implemented as the Central Conga Object:
- Acts as the orchestration layer for document generation
- Maintains lookup relationships to post-sales records (shops, leases, contracts)
- Stores email recipients for document distribution
All Conga executions: manual or automated flows through this object.
Manual Document Generation (User-Driven)
A Lightning Web Component was built to support operational users.
Capabilities
- Displays template files associated with a Conga Template record
- Allows selection of one or multiple template files
- Enables users to define or select:
- Output type
- File name
- Conga query
- Delivery method (attach vs download)
This eliminated manual document creation and removed dependency on rigid DocGen configurations.
Dynamic Document Generation (Process-Driven)
For structured post-sales processes:
- A custom button triggers document generation.
- Apex evaluates record context and selects the appropriate configuration records.
- Conga endpoint URLs are constructed dynamically using:
- Custom Metadata (environment details)
- Configuration Object (business behavior)
- Generated documents are:
- Attached to Salesforce records
- Emailed to recipients stored on the central object
Conga Triggers were intentionally not used, giving Salesforce full control over execution.
Asynchronous Processing, Reliability & Email Distribution
- Conga document generation is executed using Queueable Apex to safely handle long-running callouts and avoid UI blocking or synchronous timeout limits.
- The Queueable implementation supports:
- Controlled execution of Conga Composer API callouts
- Retry handling for transient failures or timeouts
- User notification when execution cannot be completed successfully
- As part of the same Queueable process, email delivery is handled asynchronously to ensure reliability and performance.
Email Distribution Logic
- One or multiple generated documents can be attached to a single email.
- All documents generated within the execution context are:
- Collected programmatically
- Attached to the apex email method
- Emails are sent to recipients stored on the Central Conga Execution Object.
- This approach ensures:
- Consistent delivery even when multiple documents are generated
- No dependency on synchronous email limits during document generation
Design Outcome
- Document generation and email distribution are treated as a single, atomic post-sales operation.
- Heavy processing, callouts, and email handling are isolated from user interaction.
- Improved reliability and user experience for post-sales teams generating contracts, leases, and renewal documents.
Results & Business Impact
- Replaced DocGen and manual processes with a flexible Conga-based framework.
- Centralized multiple post-sales document scenarios under one execution model.
- Reduced configuration effort for new business processes.
- Improved reliability, scalability, and maintainability.
- Enabled non-technical users to generate documents independently.
Conclusion
By clearly separating environment configuration (Custom Metadata) from business document behavior (Custom Configuration Object) and centralizing execution through Apex, the solution delivered a robust and scalable Conga document generation framework. This approach supports complex post-sales real estate processes while remaining portable across orgs and adaptable to future business needs.

