0

I wrote an apex service (called by my Account Trigger before insert and before update) that runs some complex validation , and it starts by querying for the user record of the running user since the validation needs to know their UserRole as well as some custom User field values:

Id runningUserId = UserInfo.getUserId();
User runningUser = [SELECT Id, UserRoleId, Custom_fields__c FROM User WHERE Id = :runningUserId LIMIT 1];

I shipped this service to production today and had no issues. Until just now, when (11:15 PM) I got a Developer Script Exception email with the error System.QueryException: List has no rows for assignment to SObject on my second line of the code above.

When I took the User id in the exception email and plugged it into the URL bar, I got insufficient privileges. I am a system admin, so it seems that this code execution was run by a user that does not correspond to any actual User record in my org.

I've tried googling "Salesforce system user" but haven't found anything useful. Is there some kind of root system user or something that can edit records or execute code?

3

Yes, Salesforce maintains a hidden user called "Automated Process user". The user exists at the time that an organization is created and may be used by Salesforce to make automated system-level changes in the course of providing services and features present in an organization. It is not a real user -- consider it as part of a System Admin Profile with special powers. You cannot control or configure its Profile.

You can not see detail of this user as it's know issue for now: https://success.salesforce.com/issues_view?id=a1p30000000T3izAAC

  • I see, thanks for pointing it out. It looks like the Automated Process user is also the agent that executes timed workflow actions, so that explains what I'm seeing. – OBerm May 10 '18 at 13:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.