Skip to main content
New tool CRON Expression Builder — preview next run times before you schedule Apex. Open the builder →
A 3D rendering illustrating a Salesforce Scheduled Flow icon processing a large batch of records efficiently.
Flow

Scheduled Flows for Bulk Record Updates

Scheduled Flows give you a native, configuration-light substitute for Data Loader when you need a mass update to run overnight. Batch the DML to stay inside governor limits, and switch the flow off when it is done.

Using Scheduled Flows for bulk record updates instead of Data Loader

Sometimes you need to push a change across a large number of records and Data Loader is not on the table: licensing gets in the way, or the setup friction is not worth it for a one-off. Scheduled Flows do the job natively, using processing the platform already gives you.

Why a Scheduled Flow rather than Data Loader

Data Loader is still the standard ETL tool, and in specific situations the Flow wins anyway. There is nothing external to install or configure. It costs nothing beyond the licenses and platform capability you already pay for. And the update sits alongside the rest of your business logic instead of outside it.

Batching, which is the part that matters

The whole thing lives or dies on governor limits, DML transaction counts in particular. A naive flow that walks thousands of records and updates them one after another inside a single transaction will fail.

So:

  1. Pick a conservative batch size. 200 records is a sensible default, keeping the transaction well clear of the 10,000 DML row limit once you account for retrieval and everything else going on.
  2. Use a Loop element to iterate over the queried records.
  3. Accumulate the records you want to change in a Collection Variable.
  4. Fire the Update Records element only when the collection reaches your batch size, and again at the end of the main loop for whatever is left over.

Example flow control logic

Inside the Scheduled Flow, the record processing loop should behave like this pseudo-Apex:

List<SObject> recordsToUpdate = [SELECT Id, Field__c FROM ObjectName WHERE Criteria LIMIT 5000];
Integer batchCounter = 0;
List<SObject> currentBatch = new List<SObject>();

for (SObject rec : recordsToUpdate) {
    rec.Field__c = 'New Value'; 
    currentBatch.add(rec);
    batchCounter++;

    if (batchCounter % 200 == 0) { // Execute every 200 records
        update currentBatch; // Corresponds to Update Records element in Flow
        currentBatch.clear();
    }
}

// Process any remaining records in the final, incomplete batch
if (!currentBatch.isEmpty()) {
    update currentBatch;
}

Scheduling, and turning it off again

A Scheduled Flow runs at the time you configure when you set it up, and it keeps running on that schedule, daily or weekly or whatever you chose. Two things follow.

Schedule it for off-peak hours, overnight say, so it is not competing with concurrent user transactions.

Then deactivate it by hand the moment the bulk operation completes. This is the step people forget. Leave the flow active and it re-triggers on schedule, which means another mass update nobody asked for and governor limits hit repeatedly for no reason.

The short version

A Scheduled Flow is a configuration-light native substitute for Data Loader for bulk updates. Batch the DML, 200 records at a time through collection variables, so you stay inside governor limits. Then deactivate the flow as soon as its run is finished, or it will come back around on you.

Originally reported by reddit.com

Newsletter

One email every Tuesday

New guides, tool updates, and the release-note changes that break things.

No spam. Unsubscribe in one click.

Comments

Loading comments...

Leave a Comment