Running A Batch Job Once A Minute With Spigots

Next Tutorial: Patching Bugs In Other Automation With Spigots

🧠 Overview

Salesforce’s native job scheduler is limitedβ€”you can only run scheduled jobs once per hour using standard Cron expressions. This creates bottlenecks, especially when near real-time automation is needed.

Spigots removes this limitation by allowing jobs to run as often as once a minute (or even faster), enabling a whole new class of fast-reacting, data-driven automations.


🚫 Native Limitation: Salesforce Scheduler

  • Standard scheduled jobs (like those used by DLRS) must run on a fixed schedule.
  • Fastest interval: once every hour
  • This delay limits the freshness of calculated data (e.g. rollup summaries)
  • Real-time mode is error-prone (due to governor limits or transaction rollbacks)

βœ… Spigots Solution: Always-Running Spigots

Spigots introduces atomic, composable automation units that can be:

  • Always running
  • Executed based on real-time conditions (e.g. if data exists to process)
  • Scheduled independently of native Salesforce limitations

🧩 Example: DLRS Rollup Every Minute

To run DLRS rollups more frequently, we define a Spigot like this:

Spigot:
Name: Run DLRS Rollup Job
Schedule: Always Running
Inputs:
Object: dlrs__RollupSummaryScheduleItem__c
Limit: 1
Actions:
Name: Trigger DLRS Job
Type: Spex
Subtype: Batchable
Function: RollupJob
Namespace: dlrs

πŸ” How It Works

  • Every minute (or at a configurable interval), Spigot App Configurantions run and evaluates the ‘ready to run’ Spigots.
  • If there’s at least one DLRS job waiting (via the dlrs__RollupSummaryScheduleItem__c object), it triggers the dlrs.RollupJob Batch Class.
  • This results in DLRS rollups executing roughly once a minute, instead of once an hour.

πŸ“ˆ Benefits of Frequent Scheduled Jobs in Spigots

BenefitDescription
πŸ”„ Fresh dataYour rollup fields (e.g. Last Call Time) updates quickly, improving automation accuracy
πŸ’₯ No governor errorsAvoids real-time DLRS mode, reducing risk of rollback errors
🧘 Simple setupJust define a Spigot — no special cron expressions or Apex scheduling needed

πŸ§ͺ Example Use Case: Lead Outflow

With this Spigot running every minute:

  • A completed call Task logs on a Lead
  • DLRS updates the Last Call Time field within 1–2 minutes
  • A downstream Spigot evaluates if the Lead qualifies for outflow, which depends on Last Call Time.
  • All fully automated, nearly instant, and guaranteed to be correct

🧡 Summary

Spigots supercharges scheduled jobs in Salesforce by:

  • Letting you define event-driven or high-frequency Spigots
  • Eliminating reliance on hourly cron-based limits
  • Unlocking near-real-time rollups and workflows, safely and scalably


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *