Help Center Document Generation Schedule Automatic Generation

How to Schedule Automatic Document Generation in Salesforce with Dochly

Updated July 2026 9 min read Document Generation
Scheduled document generation runs automatically at set intervals — generating and delivering documents for every qualifying record without any user action. Use it for monthly invoice runs, weekly renewal notices, daily compliance reports, and any recurring document workflow. Dochly does not have a separate in-app scheduler screen — instead, you build a native Salesforce Scheduled-Trigger Flow that calls the Dochly Generate Document action on the schedule you define. This guide walks through building that Flow end to end.

How scheduled generation works

Salesforce Flow includes a native automation type called a Scheduled-Trigger Flow — a Flow that runs automatically on a schedule you define, rather than when a record is created or updated. Dochly plugs into this native Salesforce capability: your Scheduled Flow queries the records that should receive a document, loops over them, and calls the Dochly Generate Document action once per record.

There is no separate "scheduler" screen inside the Dochly app itself — the schedule lives entirely in Salesforce Flow Builder, using standard Salesforce Setup screens you already know.

What the Flow does

Runs on the schedule you set (Once, Daily, or Weekly), retrieves the matching records with a Get Records element, loops over them, and calls the Dochly Generate Document action for each one.

What you configure

The record filter conditions (equivalent to a report's filters), the schedule frequency and start time, the template to use, and any post-generation steps like updating a field or sending an email.

If you already have a Salesforce report that shows the right records, use its filter logic as a reference — you'll rebuild the same conditions using Get Records filters inside the Flow.


Build a Scheduled Flow for automatic generation

A Salesforce Scheduled Flow runs automatically on a defined schedule and processes a collection of records. It's also the right place to combine document generation with other automation — for example, generating an invoice AND updating a field AND sending a Chatter notification, all in one scheduled run.

1

Plan the schedule and record criteria

Before building the Flow, decide exactly which records should receive a document and how often. Write down:

  • The object your records belong to — it must match your template's primary object
  • The exact filter conditions that identify the record set — e.g. "Close Date = this month", "Contract Status = Active AND End Date within 60 days"
  • The prevention field you'll use so records aren't processed twice (e.g. Invoice_Sent__c) — covered in detail below
  • The frequency: Flow Builder's scheduled trigger natively supports Once, Daily, or Weekly — see the schedule examples below for how to approximate monthly or quarterly cadences
2

Create a Scheduled Flow in Flow Builder

Setup → Flows → New Flow → Scheduled Trigger Flow. Configure:

  • Start date and time — when the first run should occur
  • Frequency: Once, Daily, or Weekly — Flow Builder does not offer a built-in monthly or custom cron option

For a monthly, quarterly, or other custom cadence, schedule the Flow to run Daily and add a Decision element right after the trigger that checks today's date (e.g. "Today = Day 1 of the Month"). The Flow only continues to the record query when the condition is true — this is the standard way to build non-daily/weekly schedules natively on the Salesforce platform.

3

Query the records with Get Records

Add a Get Records element that retrieves the collection of records to process. Set the object to your target object, and add filter conditions that match the criteria you planned in Step 1 — the same logic a Salesforce report's filters would use (e.g. Stage = "Closed Won" AND Close Date = this month AND Invoice_Sent__c = FALSE). Store the result as a record collection variable.

Get Records filters don't have built-in relative-date keywords the way reports do ("this month", "next 60 days"). Build the equivalent date range with a formula resource — using TODAY() and date-math functions — and compare your date field to that range.

If you already use a Salesforce report to see this record set, open the report and copy its filter logic into the Get Records conditions — this keeps the Flow's record selection consistent with what you can see in the report.

4

Add a Loop and the Generate Document action

Add a Loop element that iterates over each record in the collection returned by Get Records. Inside the loop, add the Dochly: Generate Document action — set Record ID to the current loop item's ID and configure the Template ID and other settings.

Always add a fault path to the Generate Document action inside the loop. A single record failure should not stop the Loop from processing remaining records.

5

Add prevention-field updates and post-generation actions

Inside the loop, immediately after the Generate Document action succeeds, add an Update Records element that sets your prevention field (e.g. Invoice_Sent__c = TRUE) on the current record. Add any other post-generation steps needed — post to Chatter, create a Task, etc. Outside the loop, add a summary notification or final update.

6

Activate and test

Save the Flow, then click Activate. Before relying on the schedule, open the Flow in Flow Builder and use Debug to run it immediately against real data — this lets you verify the Get Records filter returns the right records and that documents generate correctly. Once you're satisfied, the Flow runs automatically at the next occurrence of your configured schedule.

Salesforce API limits apply. Scheduled Flows are subject to Salesforce Governor Limits — each loop iteration counts toward DML and SOQL limits. For very large record sets (500+ records), consider a one-time Batch Document Job instead, or split the Get Records query into smaller segments across multiple Scheduled Flows to stay within limits.


Schedule configuration examples

Real-world Scheduled Flow configurations for common document workflows:

Monthly invoice run

Monthly
ScheduleFlow trigger set to Daily at 7:00 AM org timezone, with a Decision checking "Today = Day 1 of the Month"
Get Records filtersStage = "Closed Won" AND Close Date = this month AND Invoice_Sent__c = FALSE
TemplateStandard Invoice
DeliveryEmail to Contact.Email — "Your invoice is attached"
Post-generationUpdate Invoice_Sent__c = TRUE on each record inside the loop

Weekly renewal notice batch

Weekly
ScheduleFlow trigger set to Weekly, every Monday at 9:00 AM org timezone
Get Records filtersContract Status = "Active" AND End Date within next 60 days AND Renewal_Notice_Sent__c = FALSE
TemplateContract Renewal Notice
DeliveryAttach to Contract record — no email (email sent separately by account owner)
Post-generationSet Renewal_Notice_Sent__c = TRUE via Update Records inside the loop

Quarterly compliance report

Quarterly
ScheduleFlow trigger set to Daily at 6:00 AM, with a Decision checking "Today = Jan 1, Apr 1, Jul 1, or Oct 1"
Get Records filtersCase Status = "Closed" AND Case Type = "Regulatory" AND Closed Date within a previous-quarter range built from two formula resources
TemplateRegulatory Case Closure Summary
DeliveryAttach to Case record AND email to compliance team inbox
Post-generationUpdate Compliance_Doc_Generated__c = TRUE

Preventing duplicate document generation

On recurring Scheduled Flows, the most important safeguard is ensuring each record only receives a document once per cycle — not every time the Flow runs. The most reliable way to achieve this is a "prevention field" pattern.

The prevention field pattern

Step 1: Add a checkbox field to the object — e.g. Invoice_Sent__c, Renewal_Notice_Sent__c, or Document_Generated__c.

Step 2: Add this field as a filter condition in the Flow's Get Records element: Invoice_Sent__c = FALSE. This means the query only returns records that haven't had a document generated yet.

Step 3: Immediately after the Generate Document action succeeds inside the loop, add an Update Records element that sets the field to TRUE.

Result: each record is picked up by the Get Records query exactly once. On subsequent runs, the field is TRUE so the record is excluded from the query — preventing duplicate documents even if the Flow runs more than once.


Monitoring scheduled Flows

After activating a Scheduled Flow, use these monitoring touchpoints to confirm each run is completing correctly:

Dochly Documents

Dochly → Documents. Filter by template or date to confirm the documents you expect were actually generated on each run.

Flow error emails

Setup → Flow Error Emails / Setup → Paused and Failed Flow Interviews shows any run that hit a fault, along with the error detail for troubleshooting.

Scheduled Apex Jobs

Setup → Apex Jobs → Scheduled Jobs shows the Flow's next scheduled run time — every Scheduled Flow registers here natively; it isn't a Dochly-specific screen.

Checking a specific record

To verify a specific record was processed: open the Salesforce record → scroll to the Files related list, or open Dochly → Documents and filter by record. The generated document should appear with the generation date.

Next run time

Setup → Apex Jobs → Scheduled Jobs shows the exact next run datetime for your Flow, in the org's timezone. If a run didn't happen as expected, check here first for queue delays, then check Setup → Paused and Failed Flow Interviews for faults.


Best practices

Build relative date logic into Get Records

Use a formula resource (based on TODAY()) to build "this month", "next 60 days", or "last quarter" style date ranges in your Get Records filters — never hardcode dates. Relative logic updates automatically on each run, while hardcoded dates require manual Flow edits before every run.

Schedule off-peak hours

Schedule large Flows during off-peak hours — early morning before business hours (5–7 AM) or overnight. This avoids API limit collisions with user activity during business hours and reduces the risk of jobs competing with other automations.

Test with Debug before the first live run

After activating a new Scheduled Flow, open it in Flow Builder and click Debug to run it immediately against real data. Verify the record count matches your expectation, the documents generate correctly, and delivery works — before the first real scheduled run.

Always use prevention fields

For any recurring Flow, implement the prevention field pattern to protect against duplicate documents. A single misconfigured run can generate hundreds of duplicate documents — prevention fields make re-runs safe.

Review failures promptly

Check Setup → Paused and Failed Flow Interviews after every scheduled run and review any failures immediately. Failed records often have fixable data issues (missing email, empty required field) — addressing them within the same billing period prevents the customer from missing their document.

Keep one Flow per document type

Create separate Scheduled Flows for different document types — one for invoices, one for renewal notices, one for compliance reports. A single Flow handling multiple templates becomes difficult to monitor and troubleshoot when issues arise.


Frequently asked questions

The Get Records filter conditions in the Flow were incorrect — the query returned records outside the intended scope. Open the Flow in Flow Builder and review the Get Records filter conditions. A common cause is a missing condition (e.g. forgot to add Invoice_Sent__c = FALSE), causing the query to return records that should have been excluded. Correct the filters, and for any incorrectly generated documents, delete them from the affected records' Files lists.
Yes. Go to Setup → Flows → [Flow Name] → click Deactivate. The Flow is paused and will not run on its next scheduled time. All configuration is preserved. Click Activate to re-enable it. The next run after reactivation will be at the next occurrence of the configured schedule.
Salesforce Setup → Apex Jobs → Scheduled Jobs shows every active scheduled job in the org, including your Scheduled Flow, with the exact next run datetime in the org's timezone. This is a native Salesforce screen, not something Dochly adds.
Yes. Deactivate the current version of the Flow, edit the start date, time, or frequency, save (this creates a new version), then activate the new version. The run history and configuration of prior versions are preserved for reference.

Scheduled document generation now runs automatically without any user action. Final guide in this series: Salesforce document output formats: PDF, Word, Excel with Dochly — choose the right format for every document type and use case.

Dochly
Salesforce AppExchange — UTECH HUB Install Dochly on AppExchange

Rated 5 stars · Native Salesforce app · Free to install