Today3 stories · 1 brief

The Daily Org

Spring '27Sandboxes 6 Feb 2027

Curated by Abhinav (opens in a new tab)

Vol. I · No. 42The independent daily for Salesforce admins, developers and architects3 stories · 1 brief

Must-readApex and platform

Why a static Boolean Trigger guard silently skips records in bulk (opens in a new tab)

You will learn why a static Boolean recursion guard fails when a DML statement touches more than 200 records, how to reproduce the bug with a test, and how to replace it with an Id-based Set or a change-based check.

Static Boolean guard

  • One flag for the whole transaction
  • Chunk 2 onward is skipped
  • 800 of 1,000 records unprocessed
  • Insert still succeeds silently

Id-based Set guard

  • Tracks each record Id
  • New Ids in each chunk processed
  • Recursive Ids already in set skipped
  • Guards afterUpdate, not inserts
A static Boolean guard against an Id-based Set in a bulk trigger

Many Apex trigger tutorials recommend a static Boolean flag to stop a trigger from running again during recursion. The article argues this flag can silently skip records in production. Salesforce splits any DML statement touching more than 200 records into chunks of 200, running the trigger once per chunk within the same transaction. A static variable persists across those chunks, so the guard cannot distinguish a recursive call from the next batch of records, and records beyond the first chunk never get processed, though the insert still succeeds.

The problem is most likely in Batch Apex with a scope above 200, data migration scripts run from Anonymous Apex, service classes that insert or update large lists, and Flows that change many records in one element. It rarely appears in UI testing because records are saved one at a time. The article provides a test that inserts 201 Accounts and asserts that all 201 are processed. With the Boolean guard the test fails, reporting 200 processed, while a bulk-safe test catches the defect before release.

The recommended fix is to track record Ids in a Set rather than a single Boolean. Adding each Id to the set returns false when it was already present, so only genuinely new records are processed in later chunks, while a true recursive update is skipped. The article notes practical details: guard afterUpdate rather than inserts because records in before insert have no Ids yet, keep separate sets per event if both beforeUpdate and afterUpdate do work, and accept that a record updated twice on purpose is handled only once.

Often the better solution is to avoid needing a guard. Comparing field values against Trigger.oldMap and acting only on the change of interest stops recursion naturally, because the follow-up update does not change the field again. A before-insert handler that only sets fields on Trigger.new cannot cause recursion and needs no guard. The article closes with a checklist: search the org for static Boolean flags in trigger handlers, remove guards that are unnecessary, react to changes rather than every update, use Sets where a guard remains, and test every trigger with 201 or more records in one statement. The article also promotes a commercial starter kit, which is not part of the technical guidance.

Read the original at dev.to (opens in a new tab)

Also told by dev.to (opens in a new tab), dev.to (opens in a new tab)

Worth reading?

RecommendedIntegration

Route a voice agent's Salesforce calls through a small endpoint you control (opens in a new tab)

You will learn why a token-renewing middle endpoint suits a voice agent that cannot refresh OAuth tokens itself, how to set up a client credentials External Client App with a locked-down integration user, and how to log call results as Tasks without duplicates.

  1. Agent sends request with bridge key
  2. Endpoint attaches cached Salesforce token
  3. Salesforce returns success or error
  4. Endpoint passes reply back to webhook
  5. Webhook retries temporary failures
How a call result reaches Salesforce through the endpoint

The author treats Salesforce’s reply as the only proof that a call reached the CRM, so any non-success reply should trigger a retry. Because the Salesforce client credentials flow issues short-lived tokens with no refresh token, and the Dograh voice platform stores credentials only as fixed values, the design places a small HTTPS endpoint between the agent and Salesforce. That endpoint holds the Salesforce secret, caches tokens, and checks a fixed bridge key header before doing anything else.

The token logic fetches a token, reuses it, and on a 401 response fetches a fresh one and retries once, so nothing downstream has to handle expiry. For setup, the article recommends starting with an External Client App, since new Connected Apps are restricted from Spring ’26. It advises enabling OAuth and the client credentials flow, running the app as a dedicated integration user with the Minimum Access - API Only Integrations profile, and granting only read on Contacts and Leads plus create on Tasks.

For inbound calls, a pre-call data fetch can search Contacts and Leads by phone number before the agent speaks, matching on the last 10 digits to handle inconsistent formatting. The author warns to keep this fast and to confirm identity with an approved check before using any Salesforce data. After the call, a webhook files a Task on the matched record, with TaskSubtype set to Call at creation since it cannot be changed later. Retries can file duplicates, so the endpoint should track the run_id of filed Tasks and skip repeats. The article closes with testing advice: check View Trace after a live call, and test an unknown caller.

Read the original at dev.to (opens in a new tab)

Worth reading?

Architecture

Design the permission model before the screens in occupational health cases (opens in a new tab)

You will see how to split an occupational health case across objects so an employer sees fitness outcomes but never clinical detail.

Why read this

You will also see why governed picklists, data-driven thresholds and an external community help with privacy and audit.

Occupational health case

  • Case
  • Encounter
  • Exposure event
  • Restriction
  • Surveillance result
  • Employer account
A single case is split into separate objects so each role sees only its own slice

The article frames occupational health case management as a permission problem. Five roles touch each case, and the employer may learn whether a worker can lift or drive but not why. Spreadsheets and shared drives fail because they cannot enforce who sees what or show afterwards who looked.

The author argues against a single large record. The case should be split into objects for the encounter, exposure event, restriction, surveillance result, employer account and worker record, with a junction object where the employer of record differs from the work site. Restrictions carry start and end dates and a review owner, so expiry becomes a tracked state. Record types and field-level security then separate employer-visible outcomes from clinical detail.

Free text classification is treated as a privacy risk as well as a reporting problem, because a diagnosis typed into a notes field escapes every Sharing Rule. Governed picklists close that gap. Regulated rules such as blood lead level monitoring thresholds and testing frequency should live as records rather than code, so regulatory changes become configuration edits and reports draw on the same data as the rules. Correspondence is logged as case activity, and documents carry version history, classification and retention rules.

For employers and referring clinicians, the article recommends an external community rather than a hidden-field copy of the internal app, which also avoids consuming internal user licences. Migration is where legacy duplicates and inconsistent classifications surface, so it should be rehearsed in a full sandbox and validated against historical caseloads. The closing advice is to settle the permission model first, since it is the expensive part to retrofit.

Read the original at dev.to (opens in a new tab)

Worth reading?

In brief