Loading

Apex Platform Event Triggers Execute as 'Automated Process' User Instead of Causing User

Дата публикации: May 15, 2026
Описание

When an Apex trigger is configured as the subscriber of a Platform Event in Salesforce, the trigger executes as the 'Automated Process' user rather than the user who published the event (the causing user).
Example scenario: A notification Platform Event is created to log actions that require downstream notifications — such as sending an email or calling an external system. The event records the reason, message, notification type, object ID, and record name. A trigger on this event checks the notification type and, for special orders, fires a workflow rule on a custom object that sends an email template. However, when the event is published via the REST API, the email is not sent and debug logs show an error. This occurs because the trigger runs as 'Automated Process', not as the user who made the API call.
Other affected use cases: SOQL queries executed in the Automated Process user context may not return expected results, particularly when record visibility or sharing rules are user-dependent.

Решение

Apex triggers that subscribe to Platform Events execute as the 'Automated Process' system user by design in the Salesforce Platform Event architecture. This user does not have the same profile, role, or permissions as the publishing user.
Recommended Workaround — Use a Flow-Based Subscriber:
Replace the Apex trigger subscriber with an Autolaunched Flow triggered by the Platform Event. Flow-based subscribers execute as the causing user (the user who published the event), preserving the correct user context for downstream operations such as workflow rule emails, API calls, and sharing-dependent SOQL queries.
To configure a Flow-based Platform Event subscriber: In Setup, navigate to Flows, create a new Autolaunched Flow, and set the trigger to the Platform Event you want to subscribe to. Map the event fields to the flow variables and build your logic in the flow.
Note: Process Builder also executes as the causing user and can be used as an alternative; however, Process Builder is scheduled for retirement. New implementations should use Flow.

Номер статьи базы знаний

000383103

 
Загрузка
Salesforce Help | Article