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:
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];
}
}