How to Schedule Automatic Document Generation in Salesforce with Dochly
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.
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.
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.
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
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.
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.
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.
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.
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
MonthlyWeekly renewal notice batch
WeeklyQuarterly compliance report
QuarterlyPreventing 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.
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.
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.
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
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 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.
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.
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.
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.
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
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.
Rated 5 stars · Native Salesforce app · Free to install