Help Center Batch Processing Run a Batch Job from a Report

Run a Batch Document Job from a Salesforce Report with Dochly

Updated June 2026 7 min read Batch Processing
There is no "New Batch Job" screen in Dochly — a batch run is a Salesforce Flow that gathers a set of records (mirroring what a report would show) and calls Dochly's bulk generation action. This guide walks through building that Flow: naming it, building the record-source query, adding the bulk action and template, configuring per-run options, testing, and monitoring once it's running.

Before you run

Confirm these are ready before building a batch Flow:

Batch processing understood

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.

Record source verified

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.

Template tested

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.

Permission confirmed

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

1

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.

2

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
3

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.

4

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.

Dochly: Generate & Email Documents (Bulk - Collection) — action inputs
Record Id collection Required
{!ClosedWonOppIds} — 147 records
Template Id Required
{!StandardInvoiceTemplateId} — Standard Invoice (Active)
Action output Optional
batchId (Text) → store for a later Get Batch Status call
5

Configure per-run options

There's no per-job override panel — options are set by which action and variables your Flow uses:

Email or no email

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.

Throughput

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

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.

Scope

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.

6

Test and activate

Before activating, run the Flow in debug mode against a small test set:

Debug run summary
Records targeted:147 Ids from Get Records ("Closed Won — This Month")
Template:Standard Invoice (Active)
Action:Dochly: Generate & Email Documents (Bulk - Collection)
Storage:Salesforce File on each Opportunity record
Tracking record:New DH_Generation_Batch__c — Status: Queued

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.

Progress tracking

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.

Stopping a run mid-way

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

There's no pause/resume control. You can abort the underlying async Apex job from Setup → Apex Jobs, which stops further processing — records already processed retain their generated documents. To process the remaining records, call the bulk action again with an Id collection that excludes what's already done (a prevention field makes this automatic on the next run).
Your Flow's Get Records query runs at the moment you launch it — not when you last tested it. If it uses a relative date filter and records were added or removed between your test and the real run, the count differs. For time-sensitive runs, launch immediately after verifying the count, or use a fixed date filter.
A single call to the bulk action uses one Template Id for all records in the collection. For different templates, build separate Id collections and call the action once per collection/template pair within the same Flow — for example, an Enterprise Id collection with an Enterprise template, and an SMB Id collection with an SMB template, each filtered by Account Type.

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.

Dochly
Get Early Access Contact Us to Get Started with Dochly

Not on AppExchange yet — contact us and we'll set you up