Run a Batch Document Job from a Salesforce Report with Dochly
Before you run
Confirm these are ready before building a batch Flow:
You should be familiar with the two bulk actions and the custom metadata that governs throughput. If not, see Set up batch document processing first.
Run the equivalent Salesforce report (or test your Get Records element in Flow debug mode) and confirm the row count is exactly the intended record set. Every Id in the collection becomes one generation — unexpected records means unexpected documents sent to customers.
The template to be used has been previewed against a representative record from the target set. All merge fields resolve correctly, conditional logic works as expected, and the output looks correct.
You have the Dochly Admin permission set assigned to build and activate the Flow, and the Flow's running context has at least the Dochly User permission set to call the bulk actions. Verify in Setup → Users → Permission Set Assignments.
Record-source requirements
- Get Records returns record Ids, not just fields — the bulk action expects a collection of Ids. If you query full records, add a step to build an Id collection from them (e.g. a loop that assigns each record's Id into a collection variable).
- Object matches template — an Opportunity template must be paired with an Opportunity Id collection. Mismatched object types produce generation errors for every record.
- 2,000 record cap per call — if your Get Records query can return more than 2,000 rows, either add a Limit to the query or split the result into multiple calls (see the Set up batch processing guide for the looping pattern).
- Relative date filters where applicable — "This Month" beats "June 2026" for recurring runs. Relative filters stay relevant on every re-run; static dates go stale.
- Prevention filter for recurring runs — if this Flow will run more than once against overlapping data, filter out already-processed records (e.g. a checkbox field you set after generation) to avoid duplicate documents.
Step-by-step: building and running the Flow
Start building the Flow
In Setup → Flows, create a new Flow. A Screen Flow works well for an on-demand batch you trigger manually; an Autolaunched Flow (called from a button, another Flow, or a Scheduled-Trigger Flow) works for automated runs. Either way, the structure is the same: gather records, call the bulk action, optionally check status.
Name the Flow
Give it a clear, descriptive name that identifies what it generates and when it runs. Good naming makes the Flow easy to find and maintain later.
- June 2026 Invoice Run — Closed Won
- Q3 Renewal Agreements — 90-Day Pipeline
- Annual Compliance Docs — All Active Accounts
Build the record-source query
Add a Get Records element with the filters that define your target set — the same filters you'd put on a Salesforce report. Assign the results to a record collection, then use an Assignment (in a loop) or a formula to build an Id collection variable from it. Run the Flow in debug mode first and check the resulting collection size and contents before wiring it into the bulk action.
Add the bulk action and template
Add the Dochly: Generate Documents (Bulk - Collection) action element (or Dochly: Generate & Email Documents (Bulk - Collection) if you want the documents emailed as they generate). Only Active Dochly templates should be referenced — Draft or Inactive templates will fail at generation time.
Configure per-run options
There's no per-job override panel — options are set by which action and variables your Flow uses:
Use Dochly: Generate Documents (Bulk - Collection) for storage-only runs, or the Generate & Email variant to send each document to its record's recipient as it's produced.
Controlled org-wide by the Bulk_Cap, Chunk_Size, and Async_Threshold custom metadata records — not a per-run setting. Adjust the metadata if a specific run needs different throughput.
File naming follows the template's configured naming pattern. To vary it per run, use a formula or Text Template element to compute a name and pass it if the action version you're using accepts a naming override; otherwise it follows the template default.
To generate a different record set for a similar purpose (e.g. Enterprise vs SMB accounts), duplicate the Flow (or add a Decision branch) with a different Get Records filter and Id collection.
Test and activate
Before activating, run the Flow in debug mode against a small test set:
Review the record count carefully before activating, especially if using the Generate & Email action — once the Flow runs, emails go out to real recipients and cannot be recalled. If the count is unexpected, fix the Get Records filter before running against production data.
Once the debug run confirms correct behaviour, activate the Flow (if Autolaunched) or run it (if a Screen Flow). The bulk action call runs asynchronously by default — you can navigate away once it's started.
While the batch runs
After the bulk action call starts, Dochly creates a DH_Generation_Batch__c record to track it, with Total, Completed, Failed, Cancelled, and Status fields. There's no live Active Jobs panel in the Dochly app — you track progress by querying or reporting on this record, or by calling Dochly: Get Batch Status with the batchId your Flow captured.
Build a Salesforce report or list view on DH_Generation_Batch__c filtered to Status = In Progress, or call Dochly: Get Batch Status from a follow-up Flow. See Monitor and track batch jobs for full monitoring detail.
There's no Cancel button in Dochly. To stop a run, abort the underlying async Apex job from Setup → Apex Jobs. Records already processed keep their documents; the DH_Generation_Batch__c Status reflects Cancelled once processing stops.
After the batch completes
When the run finishes, the DH_Generation_Batch__c record's Status moves to Completed, Completed With Errors, or Failed. Check its Total/Completed/Failed/Cancelled fields for the outcome, and spot-check 3–5 records in Salesforce to confirm generated documents appear in Files with correct names and content.
Re-running a batch
There's no "Run Again" button — re-running means running the Flow again, either manually or by re-triggering the Autolaunched Flow. If you built a prevention filter into your Get Records query (Step 3), the re-run's Id collection automatically excludes already-processed records.
For regular recurring runs, wrap this Flow in a native Scheduled-Trigger Flow instead of manually re-running it each time. Scheduled-Trigger Flows fire automatically at your configured interval.
Frequently asked questions
Your batch is running. Next in this series: Schedule a batch document run in Salesforce with Dochly — wrap this Flow in a native Scheduled-Trigger Flow to run automatically on a daily, weekly, or monthly cadence without manual intervention.
Not on AppExchange yet — contact us and we'll set you up