ForceChallenges
ProblemsDailyNotesInterview
Sign in

Practice

All problemsSOQL practiceApex trigger challengesDaily challengeOpportunityTrigger.oldMapBefore UpdateBulkificationContactValidationGROUP BYSemi-JoinAccountBefore Insert

Interview questions

All questionsAdminAdministrationApexApex TriggerAsync ApexDevelopmentField ServiceField ServiceIntegrationLwc

By company

DeloitteSalesforceAccentureInfosysPwCCognizant

Learn

Study notes

ForceChallenges

AboutContact usPrivacy PolicyTerms of ServiceFor AI assistants (llms.txt)
© 2026 ForceChallenges · Salesforce SOQL & Apex trigger practice
Integration questions40 of 100
IntegrationMedium 2 min read

How do Platform Event triggers execute automated processing upon receiving published event messages?

Answer

Basics: Triggers on platform events let Salesforce itself react to a message, for example to update records or call an external system. Only the after insert context is supported, because events are not editable or deletable.

How it works:

  1. A publisher puts events on the bus.
  2. The platform delivers them to the trigger in batches (up to 2,000 messages by default per invocation).
  3. The trigger runs as the Automated Process user unless you configure another user with PlatformEventSubscriberConfig.
  4. The trigger runs in its own transaction with its own governor limits, and Trigger.new holds the batch of events.
  5. If it fails, you can throw EventBus.RetryableException for the platform to redeliver the batch, up to a maximum number of retries.
  6. The trigger tracks its position through a replay ID checkpoint. By default, an uncaught failure moves on.

Advanced / deep dive: A subscriber config lets you set the running user and a smaller batch size, which helps when each event triggers heavy work or callouts. You can also call EventBus.TriggerContext.currentContext().setResumeCheckpoint(replayId) to commit partial progress so a retry does not repeat work already done. Triggers should be idempotent, because redelivery and at-least-once delivery are possible. Keep the trigger thin and use a handler. A Flow subscribed to the event is the low-code alternative.

Code / config example:

apex
trigger OrderEventTrigger on Order_Event__e (after insert) {
    List<Task> tasks = new <Task>();
     (Order_Event__e e : Trigger.new) {
        tasks.add( (Subject =  + e.Order_Id__c, Status = ));
        
        EventBus.TriggerContext.currentContext().setResumeCheckpoint(e.ReplayId);
    }
     {
        insert tasks;
    }  (DmlException ex) {
          .RetryableException( + ex.getMessage());
    }
}
Practice SOQL & Apex
PreviousWhat architectural components make up a robust integration logging and auditing framework in Salesforce?Next How do external CometD client applications authenticate and subscribe to real-time Salesforce streaming channels?

More Integration questions

  • How do PushTopics combine SOQL query criteria with real-time streaming notifications in Salesforce?
  • How do webhook security mechanisms verify the authenticity of incoming HTTP notifications from external systems?
  • How do federated identity and SAML single sign-on streamline authentication across enterprise integration landscapes?
  • How do CORS settings permit authorized web applications to perform cross-origin REST requests against Salesforce?
  • How do rate limiting and throttling mechanisms protect Salesforce endpoints from excessive traffic spikes?
List
for
new
Task
'Review order '
'Not Started'
// Remember the last replay ID processed
try
catch
throw
new
EventBus
'Retry: '

Hidden gotchas & must-remember points:

  • Only after insert is supported. There is no before context and no update trigger.
  • The running user is Automated Process by default, so CreatedBy on records and sharing behave differently from the publisher's context.
  • Retries are limited (verify the current count), after which the batch is skipped.
  • A callout in a trigger needs a @future or Queueable approach, since triggers cannot call out directly.
  • Debug logs for the trigger need a trace flag on the Automated Process user.
  • Event trigger processing is not guaranteed to be instant.

Best practice: Keep the handler idempotent, set a suitable batch size, and use resume checkpoints for large batches.

IntegrationEvent TriggersAsynchronous Processing