I have a custom platform event that I using and I have an apex trigger handling it. The apex trigger is calling a method in another apex class that has a query on PersonAddress fields on the Account WITH USER_MODE. I am getting the following error:

FATAL_ERROR System.QueryException: No such column 'PersonMailingCity' on entity 'Account'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.

How can I give the Automated Process User access to these fields. I have already tried adding a permission set that has access to BillingAddress and ShippingAddress on Account, as well as MailingAddress on Contact, but that didn't resolve it. Removing WITH USER_MODE resolves the issue but I would rather keep that as other code uses that method as well.


trigger CustomEventTrigger on Log__e(after insert) {
    new CustomEventTriggerHandler(Trigger.new, true).run();

Apex Class:

public with sharing class CustomEventTriggerHandler extends TriggerFramework {
    private List<Custom_Event__e> events = new List<Custom_Event__e>();
    private Boolean shouldThrow = false;

    public CustomEventTriggerHandler(List<Custom_Event__e> events, Boolean shouldThrow) {
        List<Account> accts = AccountQueries.getPersonAddress();

public without sharing class AccountQueries {
    public List<Account> void getPersonAddress(){
        return [SELECT Id, PersonMailingCity FROM Account WITH USER_MODE LIMIT 5];
  • Does the user that fires the platform event have the right level of access to the fields?
    – Nick C
    Jan 15 at 2:51
  • Yes I can access it with Sys Admin just fine, but that should not matter as the platform event is run under the Automated Process User.
    – awh01
    Jan 15 at 3:40

1 Answer 1


When a trigger subscribes to a platform event, the running user becomes the automated process user. This can cause problems with CRUD/FLS like you're seeing here.

When a flow subscribes to a platform event, it runs as the user that fired the platform event. i.e. This is usually a regular user of the system, not the automated process user.

We've used this to resolve these kinds of issues. We moved the logic from our trigger to an invokable, and then subscribed to the platform event using a flow that then invokes this logic.

The result is the code running as a user, and things like WITH USER_MODE work properly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .