# Real-Time Document Generation with Runtime Variables

This test drive showcases generating documents using dynamic runtime variables, populating an invoice through a guided Screen Flow that accepts custom input directly from the user.

> Kind: Test drive · Updated: Jul 4, 2026

## Introduction

In the test drives Manual Doc Gen and Automated Doc Gen, we demonstrated how CloudFiles Doc-Gen enables users to generate customizable documents (DOCX, XLSX, PPTX, or PDFs) using templates and Salesforce record data.

This test drive showcases the next level: generating documents using dynamic runtime variables. Instead of relying solely on Salesforce field values, you’ll populate an invoice through a guided Screen Flow, which accepts custom input directly from the user and generates a document on the fly.

In order to access this test drive, head over to our Salesforce AppExchange listing & click on the Try It button. Enter your information to open the test drive org. Once the test-drive is open, navigate to this article within the Instructions tab of the Test Drive.

## Instructions

To test out this feature, follow the simple instructions below:

- Go to Opportunities tab and create a new Opportunity with basic details.
- Once the record is saved, open it and click the Generate Invoice button.

![](https://media.help.cloudfiles.io/td-real-time-document-generation-with-runtime-variables-sf/01.png)

- This launches the CloudFiles: Opportunity Dynamic Invoice DocGen Screen flow. You’ll now see a guided screen where you can enter your own runtime details.

![](https://media.help.cloudfiles.io/td-real-time-document-generation-with-runtime-variables-sf/02.png)

- In the Invoice Details section, fill out information such as the invoice number, who prepared it, the document name, and date/time.

![](https://media.help.cloudfiles.io/td-real-time-document-generation-with-runtime-variables-sf/03.png)

- Choose whether you want to generate a PDF or DOCX file.

![](https://media.help.cloudfiles.io/td-real-time-document-generation-with-runtime-variables-sf/04.png)

- In the Contact Details, enter the customer's information, including Email (make sure it's valid — the document will be emailed here).

![](https://media.help.cloudfiles.io/td-real-time-document-generation-with-runtime-variables-sf/05.png)

- Under Products, toggle ON the Products you wish to be included as Line Items in the Invoice and specify quantity and unit price.

![](https://media.help.cloudfiles.io/td-real-time-document-generation-with-runtime-variables-sf/06.png)

- In the Subscription Period, set the start and end dates for the billing cycle.

![](https://media.help.cloudfiles.io/td-real-time-document-generation-with-runtime-variables-sf/07.png)

- Lastly, add any custom notes for the customer using the Rich Text Editor in Note to Customer section.

![](https://media.help.cloudfiles.io/td-real-time-document-generation-with-runtime-variables-sf/08.png)

- When you're ready, click Generate. Within seconds, the invoice will be created and attached to the Files related list of the opportunity.

![](https://media.help.cloudfiles.io/td-real-time-document-generation-with-runtime-variables-sf/09.png)

- You’ll also receive an email with the generated file as an attachment.

## Implementation

This demo is powered by Salesforce Flow Builder combined with Generate Document (Sync) Flow Action. The key components of the flow include:

- Screen elements to collect runtime input from the user.
- Assignment elements to map these inputs to variables.
- A Generate Document (Sync) action that invokes the Doc-Gen process using:
- Template ID
- File type
- Runtime variables
- Destination
- Record context

The runtime values are not pulled from fields — instead, they’re entered by the user at runtime and passed as Runtime Variables.

The below image displays the Flow being triggered behind this demo:

![](https://media.help.cloudfiles.io/td-real-time-document-generation-with-runtime-variables-sf/10.png)

The below image displays the 'Invoice' Template configuration in MS Word:

![](https://media.help.cloudfiles.io/td-real-time-document-generation-with-runtime-variables-sf/11.png)

CloudFiles supports a variety of variable types, including:

- Runtime Variables (entered via flows)
- Record Single Variables (individual records)
- Record Collection Variables (lists of records)

Each variable can be configured with a specific data type such as String, Boolean, Integer, Date, Time, DateTime, Double, and Rich Text.

![](https://media.help.cloudfiles.io/td-real-time-document-generation-with-runtime-variables-sf/12.png)

## Beyond this Test Drive

The ability to generate documents synchronously with runtime variables unlocks powerful use cases across industries. Here are some practical scenarios:

### Interactive Quote Generation

Use runtime variables in guided screen flows where sales reps input discounts, special terms, or custom product bundles, and instantly generate a customer-ready quote.

Example: A sales rep enters runtime values during a call with a prospect and immediately produces a tailored Quote PDF with discounts and custom terms that can be emailed on the spot.

### On-Demand Contracts & Agreements

Legal or HR teams can enter runtime values such as role, compensation, and start date into a flow, dynamically adjusting contract clauses.

Example: An HR manager inputs details for a new hire and instantly generates a ready-to-sign Employment Contract PDF with clauses based on runtime conditions.

### Custom Invoices with Dynamic Line Items

Finance teams add runtime details such as tax rates, subscription dates, or additional charges into flows to generate invoices in real-time.

Example: An accounts executive generates a monthly Subscription Invoice PDF where runtime values define billing dates and dynamic line items are calculated immediately.

### Personalized Customer Communications

Service reps use runtime variables to insert details like SLA commitments, complaint descriptions, or resolution notes into pre-defined templates.

Example: A support agent generates a Case Resolution Letter PDF with runtime-entered troubleshooting steps and commitments, emailed directly to the customer.

### Secure Document Delivery with Flow-Controlled Encryption

Sensitive documents can be generated with PDF encryption settings defined at runtime, such as viewer passwords or restricted printing.

Example: A compliance officer generates a Compliance Report PDF where the viewer password is dynamically set using runtime variables before the document is shared externally.

### Event-Specific or Time-Sensitive Documents

Marketing teams capture runtime details such as attendee names, event sessions, or offers and generate personalized documents instantly.

Example: A marketing coordinator uses runtime inputs to generate Event Participation Certificates PDF for attendees with dynamic QR codes included.

Synchronous Document Generation - Unlike other tools that use delayed async methods, CloudFiles supports real-time (sync) document generation. This means:

- No delays or polling
- Instant file availability for email, attachments, or external storage
- Seamless experience for users and automation flows

With CloudFiles’ runtime variables + synchronous generation, Salesforce users can build workflows where documents are customized in real-time and immediately usable — whether for approvals, emails, secure sharing, or client communication.
