Can someone clarify when a Trigger executes on a single record vs. multiple in one context?

If the external system is doing a simple REST API call into Salesforce (albeit many of them very quickly together, even in parallel), Salesforce will treat each call as a separate Transaction, and triggers will run on each item separately.

In general, multiple records are only processed together if a singular action was called on multiple records at once (like mass edit on a list view, uploads from a CSV, or custom VF / Aura / LWC components that intentionally call an insert/update on multiple SObject records at once).

There are a number of API protocols though that will ensure that bulk records will come into Salesforce, and thereby the trigger will handle them in bulk appropriately. See the Bulk API trailhead and REST API Composite documentation for some guidance.


In addition to @BrianMiller answer,

If one or more publishers publish Platform Event Foo__e as follows

  • T(0) - publish 10 Foo__e
  • T(1) - publish 3 Foo__e
  • T(2) - publish 6 Foo__e

then the trigger that subscribes to Foo__e could see anywhere from:

1 to all 19 (and anything in between) Foo__e in a single transaction as SFDC Platform Event subscription code will "batch" Platform Events into a single transaction using rules that are opaque.