Can I give the Automated Process user access to an apex Controller? - Answers - Salesforce Trailblazer Community
Trailblazer Community
Ask Search:
Alia BurdickAlia Burdick 

Can I give the Automated Process user access to an apex Controller?

We have a process that is called from a platform event, which sends a visualforce email template in an email alert. 

We are getting an error when the process builder is fired: 

Error element myRule_1_A1 (FlowActionCall).
We couldn't process the email template. Error Message: core.email.template.TemplateRenderingException: system.security.NoAccessException: You do not have sufficient privileges to access the controller: BrokerDeclineEmailTemplate

Flow Interview Details
Interview Label:
Current User: Automated Process (00580000003HZZt)
Start time: 3/7/2018 12:28 PM
Duration: 0 seconds

You can see here the Current User is Automated Process. 

BrokerDeclineEmailTemplate is an Apex Controller that is referenced in the visualforce email template markup. 

I cannot find any way to allow access to the Apex Controller to that Automated Process user. 

Why would the Automated Process user, which presumably has the same (if not more) permissions as a System Admin, not have access to this Controller? 

And if it doesn't automatically have access, is there any way around this error? 
Alexis KSIGZKIEWICZAlexis KSIGZKIEWICZ
Hello Alia,

Your admin (if you're not) can allow the security on Apex Class foreach profile:
Setting --> Apex Class --> YourController --> Security --> Add Enabled Profile (Automated Process User Profile)

Alexis
Alia BurdickAlia Burdick
Hi Alexis - 

Thanks for the quick response. Unfortunately Automated Process is the system user that Salesforce uses to run process automation when not running in user mode. If there is a profile that accompanies this user it is not accessible under the security for Apex Classes. Currently all profiles available have access to the class. 

If there was a way to get to the Automated Process user profile to grant Apex Class Access that would be great - but I haven't found way to navigate to that profile.
Alexis KSIGZKIEWICZAlexis KSIGZKIEWICZ
Alia,

Indeed I forgot this User...
I don't know if the settings for this user are available..

I can just advise to Open a Case to Salesforce...

Alexis
Alia BurdickAlia Burdick
Hi all. Thank you for your responses. I've opened a case with Salesforce, although the support agent I'm working with doesn't seem to be familiar with the Automated Process user, so I haven't been able to get very far. Hopefully we'll get somewhere with that. I'll post here with any resolution.
Sabina EneSabina Ene
Hi Alia,

Do you have any update on this, please? I am facing the same issue. 

Thank you!
Sabina
Prashant YadavPrashant Yadav
Hi @Alia,
Any updates on this? I am facing the same issue. I am trying to send VF email and it has a VF component inside the template and its giving me SendEmail failed. First exception on row 0; first error: INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY, insufficient access rights on cross-reference id: []
Alia BurdickAlia Burdick
Hi Prashant -

Unfortunatley we never did figure out how to get that that error resolved with the Automated Process User. Earlier in the process there was a Trigger involved that invoked the code later on - we removed the trigger and replaced that with a Process Builder and all of a sudden it started working. 

Not sure if that will be useful for you in the way your process is set up. 

Good luck! 
Prashant YadavPrashant Yadav

Hi Alia,
Thank you for instant response, really appreciate that. Even I got rid of Platform Triggers and now Using Process Builder and APEX class with @InvocableMethod and its working fine.  

Thank you so much!

Danielle MorseDanielle Morse
Looks like Matt provided a workaround over on Salesforce Success (https://success.salesforce.com/ideaView?id=0873A0000003aTkQAI)