Help Center Document Generation Schedule Automatic Generation

How to Schedule Automatic Document Generation in Salesforce with Dochly

Updated June 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 supports two scheduling approaches: the native Dochly scheduler (simpler, no-code) and Salesforce Scheduled Flows (more customizable). This guide covers both.

Two scheduling methods — which to use

Recommended

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.

Advanced

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.

1

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.

2

Open Scheduled Jobs in Dochly

Go to the Dochly app → Batch JobsScheduled 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.

3

Configure the schedule

Set when the job runs. Dochly supports several schedule types:

Monthly

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.

Weekly

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.

Daily

Runs every day at a set time — e.g. 6:00 AM. Best for compliance documents and time-sensitive daily reports.

Custom (cron)

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.

4

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
5

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.

1

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
2

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.

3

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

Monthly
Schedule1st of each month at 7:00 AM org timezone
Report 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 (via report filter on next run)

Weekly renewal notice batch

Weekly
ScheduleEvery Monday at 9:00 AM org timezone
Report filtersContract Status = "Active" AND End Date = 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 post-generation Flow action

Quarterly compliance report

Quarterly
ScheduleCustom cron: 1st day of Jan, Apr, Jul, Oct at 6:00 AM
Report filtersCase Status = "Closed" AND Case Type = "Regulatory" AND Closed Date = LAST QUARTER
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 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.

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 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.

Checking a specific record

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.

Next run time

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

Use relative date filters in reports

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 off-peak hours

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.

Test with "Run Now" before first live run

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.

Always use prevention fields

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.

Review failures promptly

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.

Keep one template per job

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

The Salesforce report filters were incorrect — the report returned records outside the intended scope. Open the report in Salesforce and review the filter conditions. A common cause is a missing filter (e.g. forgot to add Invoice_Sent__c = FALSE), causing the report to return records that should have been excluded. Correct the report filters, and for any incorrectly generated documents, delete them from the affected records' Files lists.
Yes. Go to Dochly → Batch Jobs → Scheduled Jobs → [Job Name] → click Deactivate. The job 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.
The scheduled job detail page shows the next 5 upcoming run times. You can also see all active Salesforce scheduled jobs (including Dochly jobs) in Salesforce Setup → Apex Jobs → Scheduled Jobs — this shows the exact next run datetime in the org's timezone.
Yes. Deactivate the job first, then edit the schedule settings, then reactivate. Editing the schedule of an active job may require a deactivate/reactivate cycle for the schedule change to take effect. The run history is preserved across schedule changes.

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