How to Schedule Automatic Document Generation in Salesforce with Dochly
Two scheduling methods — which to use
Dochly Native Scheduler
Configure recurring document jobs directly in Dochly → Batch Jobs → Scheduled Jobs. Uses a Salesforce report as the record source. Includes built-in progress monitoring, per-record error logging, and completion notifications. No Flow building required. Best for most scheduled document workflows.
Salesforce Scheduled Flow
Build a Scheduled Flow in Salesforce Flow Builder that iterates over a record collection and calls the Dochly Generate Document action per record. More flexible for complex logic (conditional branching, multi-step workflows) but requires Flow admin knowledge. Best when generation is one step in a larger automated workflow.
For most scheduled generation needs — monthly invoices, renewal notices, compliance batches — the Dochly native scheduler is faster to configure, easier to monitor, and handles errors more gracefully than a Scheduled Flow. Use Scheduled Flow when generation must be combined with other Flow actions in a single automated sequence.
Method 1 — Dochly native scheduler
The Dochly native scheduler creates recurring batch document jobs that run automatically on your configured schedule. Each run uses a live Salesforce report to determine which records get documents — so the report's filter criteria determine the record set for each run without any changes to the job configuration.
Prepare the Salesforce report
Before creating the scheduled job, set up the Salesforce report that defines which records get documents on each run. The report must:
- Be based on the same object as your template's primary object
- Include the Record ID column
- Use relative date filters (e.g. "this month", "next 60 days") so the results update automatically on each run without manual changes
- Be saved in a public or shared folder accessible to the running user
For recurring jobs, relative date filters are essential. A filter like "Close Date = This Month" automatically shows the right records each month without any updates to the report.
Open Scheduled Jobs in Dochly
Go to the Dochly app → Batch Jobs → Scheduled Jobs tab → click New Scheduled Job. The scheduled job configuration panel opens.
Give the job a clear descriptive name — e.g. "Monthly Invoice Run", "Weekly Renewal Notices 60-Day", "Quarterly Compliance Reports". The name appears in the job history log and notification emails.
Configure the schedule
Set when the job runs. Dochly supports several schedule types:
Runs on a specific day of each month — e.g. 1st of the month at 7:00 AM. Best for month-end billing runs and monthly statement generation.
Runs on a specific day of each week — e.g. every Monday at 9:00 AM. Best for renewal notice batches and weekly activity summaries.
Runs every day at a set time — e.g. 6:00 AM. Best for compliance documents and time-sensitive daily reports.
Advanced — specify any schedule using cron syntax. Best for complex schedules like "first business day of each quarter" or "last Friday of each month".
Also configure the timezone for the schedule — use your org's primary timezone to ensure the job runs at the expected local time.
Configure source, template, output, and delivery
Complete the remaining job configuration:
- Source: Select the Salesforce report prepared in Step 1
- Template: Select the Active Dochly template to use for this run
- Output format: PDF (recommended) or DOCX
- Storage: Attach to originating record (recommended) — creates a Salesforce File on each record
- Email delivery: Optional — set the recipient field and email template if documents should be sent to customers automatically on each run
- Notification: Set an admin email address to receive a completion summary after each run
Activate and monitor the first run
Click Activate to enable the scheduled job. The job will run automatically at the next occurrence of your configured schedule.
To run immediately for testing before the first scheduled run, click Run Now on the job detail page. This triggers the job immediately using the current report results — useful for verifying configuration before the first real run.
After each run, view the job history in Dochly → Batch Jobs → [Job Name] → Run History. Each run shows the date, record count processed, successes, failures, and any error details.
Method 2 — Salesforce Scheduled Flow
A Salesforce Scheduled Flow runs automatically on a defined schedule and processes a collection of records. Use this method when document generation is part of a larger automated workflow — for example, generating an invoice AND updating a field AND sending a Chatter notification, all in one scheduled automation.
Create a Scheduled Flow in Flow Builder
Setup → Flows → New Flow → Scheduled Trigger Flow. Configure:
- Run flow on: A schedule
- Frequency: Daily, Weekly, or Once
- Start date and time
- Object: The primary object to process records from
- Filter records: Add SOQL filter conditions to identify the record set
Add a Loop and the Generate Document action
The Scheduled Flow provides a collection of matching records. Add a Loop element that iterates over each record in the collection. 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 post-generation actions and activate
Inside the loop, after the Generate Document action, add any additional automation steps needed — update a field on the record, post to Chatter, create a Task, etc. Outside the loop, add a summary notification or final update. Activate the Flow and test with "Run Now" from the Flow detail page.
Salesforce API limits apply. Scheduled Flows are subject to Salesforce Governor Limits — each loop iteration counts toward DML and SOQL limits. For large record sets (500+ records), use the Dochly native scheduler instead — it handles batch processing outside the Salesforce transaction context and avoids governor limit errors.
Schedule configuration examples
Real-world scheduled job configurations for common document workflows:
Monthly invoice run
MonthlyWeekly renewal notice batch
WeeklyQuarterly compliance report
QuarterlyPreventing duplicate document generation
On recurring scheduled jobs, the most important safeguard is ensuring each record only receives a document once per cycle — not every time the job 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 in the report: Invoice_Sent__c = FALSE. This means the report only returns records that haven't had a document generated yet.
Step 3: After generation, update the field to TRUE. Do this via a post-generation Flow action triggered by the Dochly Generation Status = "Success" output, or via a Salesforce trigger on ContentDocument creation.
Result: each record appears in the scheduled job report exactly once. On subsequent runs, the field is TRUE so the record is excluded from the report — preventing duplicate documents even if the job runs multiple times.
Monitoring scheduled jobs
After activating a scheduled job, use these three monitoring touchpoints to confirm each run is completing correctly:
Dochly run history
Dochly → Batch Jobs → [Job Name] → Run History. Shows every run — date, record count, successes, failures. Click any run for the full detail log.
Completion email
If you configured a notification email on the job, you receive a summary after each run — total records, success count, failure count, and a link to the full log.
Failure alerts
Dochly sends an alert email if a run has failures — even if most records succeeded. Review failed records in the run log and fix data issues before the next scheduled run.
To verify a specific record was processed: open the Salesforce record → scroll to Files related list. The generated document should appear with the generation date. Or open the Dochly activity panel on the record to see the generation event log.
The scheduled job detail page shows the next scheduled run time in your configured timezone. If a job didn't run when expected, check the Salesforce Scheduled Apex Jobs list (Setup → Apex Jobs) for any queue delays.
Best practices
Always use Salesforce relative date filters ("This Month", "Next 60 Days", "Last Quarter") in your source reports — never hardcoded dates. Relative filters update automatically on each run, while hardcoded dates require manual report edits before each job.
Schedule large jobs 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 job, click "Run Now" to trigger an immediate test run. Verify the record count matches your expectation, the documents generate correctly, and delivery works — before the first real scheduled run.
For any recurring job, 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 the run history 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 jobs for different document types — one for invoices, one for renewal notices, one for compliance reports. A single job using 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