Skip to main content
SFDC Developers
Flow

Scheduled Flows for Bulk Record Updates

Vinay Vernekar · · 3 min read

Using Scheduled Flows for Bulk Record Updates as a Data Loader Alternative

For technical professionals needing to perform large-scale record manipulation without relying on external tools like Data Loader—whether due to licensing constraints or immediate setup friction—Salesforce Scheduled Flows offer a viable, native automation solution. This approach leverages the platform's internal processing capabilities.

Rationale for Scheduled Flows Over Data Loader

While Data Loader is the standard ETL tool, Scheduled Flows present advantages in specific scenarios:

  • Zero External Dependency: No external application installation or configuration is required.
  • Cost-Effective: Utilizes existing Salesforce licenses and platform capabilities.
  • Automation Integration: Updates can be tightly integrated with other platform business logic.

Implementation Strategy: Batching and Scheduling

The key to successfully using Scheduled Flows for bulk updates is adherence to governor limits, particularly DML transaction counts. A naive implementation attempting to update thousands of records sequentially within a single transaction will fail.

The solution involves:

  1. Defining a Batch Size: Set a conservative batch size (e.g., 200 records) to ensure the transaction stays well within the 10,000 DML row limit, accounting for retrieval and other operations.
  2. Looping and Collection: Use a Loop element to iterate over the queried records.
  3. Collection Variables: Accumulate the records targeted for update into a Collection Variable.
  4. DML Execution within the Loop: Execute the Update Records element only when the collection size reaches the defined batch limit, or at the end of the main loop iteration.

Example Flow Control Logic (Conceptual)

Within the Scheduled Flow, the record processing loop should look functionally similar to this pseudo-Apex structure:

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 Deactivation

Scheduled Flows execute based on the time configured during their initial setup. Since they are designed to run once per the specified schedule (e.g., daily, weekly), careful management is necessary:

  1. Set Appropriate Timing: Schedule the flow to run during off-peak system usage hours (e.g., overnight) to minimize impact on concurrent user transactions.
  2. Mandatory Deactivation: Crucially, the flow must be manually deactivated immediately after it has successfully completed its bulk operation. If a Scheduled Flow is left active, it will re-trigger according to its schedule, potentially leading to unintended, repeated mass updates or hitting unintended governor limits repeatedly.

Key Takeaways

  • Scheduled Flows offer a configuration-light, native alternative to Data Loader for bulk updates.
  • Implement robust batching logic (e.g., batch size of 200) using collection variables to manage DML operations within governor limits.
  • Always ensure the Scheduled Flow is deactivated immediately after its required execution cycle is complete to prevent recurrence.

Share this article

Vinay Vernekar

Vinay Vernekar

Salesforce Developer & Founder

Vinay is a seasoned Salesforce developer with over a decade of experience building enterprise solutions on the Salesforce platform. He founded SFDCDevelopers.com to share practical tutorials, best practices, and career guidance with the global Salesforce community.

Comments

Loading comments...

Leave a Comment

Trending Now