Sub topic 12
Who the flow runs as and what it can access
This chapter covers the identity and permissions a flow uses when no one is clicking through it. It assumes you can build a simple autolaunched or schedule-triggered flow and know Salesforce profiles, permission sets, and sharing at a basic level. Reading the Apex snippet at the end is optional.
Why run context matters
A screen flow always has a person in front of it. Autolaunched and scheduled flows often don't. A scheduled flow starts at 2:00 AM with nobody signed in, and an autolaunched flow may be started by a trigger, a batch job, or an integration. Two questions follow:
- Which user is recorded as running it? This affects ownership, audit fields, and emails.
- Which records and fields can it read and change? This is decided by the flow's context setting and by who or what launched it.
Wrong answers cause two kinds of failures. In the first, the flow can't see records and silently processes nothing. In the second, the flow can see and change everything, so users reach data they should not.
Who the flow runs as
A schedule-triggered flow has no user session behind it. Salesforce runs it as the Automated Process user, a built-in system user. You will see it in these places:
- Created By and Last Modified By on records the flow creates or updates.
- Owner on records the flow creates, unless you set the owner explicitly.
- The history of fields changed by the flow.
An autolaunched flow has no identity of its own. It takes its identity from whatever starts it:
| Started by | Effective user |
|---|---|
| Another flow (Subflow) | The user or process running the parent flow |
| Apex (`Flow.Interview`) | The user running the Apex code |
| REST API invocable action | The user who authenticated the API call |
| Record-triggered flow that calls it | The user whose change fired the trigger |
| Scheduled flow that calls it | Automated Process |
Because the Automated Process user owns records by default, a scheduled flow that creates Tasks or Cases will assign them to a system user nobody monitors. Add an assignment step. For example, use a Get Records element to find the account owner, then store that Id in the new record's OwnerId field.
The context setting: How to Run the Flow
Flow Builder has a setting that controls how sharing is applied. Open Settings, then Advanced, then How to Run the Flow. You will see three choices:
- User or System Context: Depends on How the Flow Is Launched. This is the default. The flow follows the launcher's context. The exact behavior varies by flow type and launch method, so don't assume it.
- System Context with Sharing: Respect User Access to Records. The flow runs in system mode but obeys record sharing for the running user.
- System Context without Sharing: Grant Access to All Records. The flow sees and edits every record, whatever the sharing rules say.
Treat these as the sharing layer only. Salesforce docs describe flows as running in system mode with respect to object permissions and field-level security (FLS), so a flow can often read or write a field the running user couldn't touch directly. Screen components that display fields are the main exception, because they respect the user's access. Check the current Salesforce documentation for your release, then confirm with a test run as a restricted user.
Choosing a setting
- A scheduled flow that sweeps the whole org, such as closing stale Cases, normally needs to see every matching record. Make that choice explicit and don't rely on the default.
- An autolaunched flow called by a user-facing process should usually respect sharing. Choose System Context with Sharing, so users only affect records they could normally access.
- An autolaunched flow that deliberately goes beyond the user's access, such as an approval helper that reads a restricted record, can use without Sharing. Document why, because it is easy to forget later.
Permissions needed to build, run, and call flows
Running as Automated Process doesn't remove all permission checks. These still apply:
- Building and editing: a person needs the Manage Flow permission, or the equivalent system permission, to create, edit, and activate flows.
- Running a flow from a user session: the user needs access to run it. Screen flows and some launch paths use Run Flows or profile and permission set flow access. Check which applies to your launch path.
- Calling through the API: the API user's profile or permission set must allow the calls you make. An integration user with too few permissions often gets errors when it invokes the invocable action endpoint.
Security rules vary between orgs and releases, so verify each assumption in your own sandbox.
Seeing the run context
You can check who ran a flow without leaving the data. This anonymous Apex lists the most recent Cases and who created or last modified them. After a scheduled run, flow-created records usually show Automated Process in these fields:
List<Case> recent = [
SELECT Id, CaseNumber, CreatedBy.Name, LastModifiedBy.Name, Owner.Name
FROM Case
ORDER BY LastModifiedDate DESC
LIMIT 10
];
for (Case c : recent) {
System.debug(c.CaseNumber + ' | created by ' + c.CreatedBy.Name
+ ' | modified by ' + c.LastModifiedBy.Name
+ ' | owner ' + c.Owner.Name);
}Common problems
- The flow finds zero records. In a sharing-respecting context, the running user may not see the records you expected. Switch the setting only after you understand why.
- Records show a system user as owner. The flow never set
OwnerId, so Automated Process owns them. - A flow works for admins and fails for others. The flow may depend on user access, or on a user permission that regular users lack. Test as a standard user.
- Notifications go to the wrong person. Emails sent from a flow may name the system user as sender, or error emails may go to someone other than the person who owns the flow. Name an owner for each flow and test the notification path.
- Behavior changes when you reuse the flow. An autolaunched flow set to the default context behaves differently depending on the launcher. Pin the setting.
Exercise
A scheduled flow creates follow-up Tasks for stale Opportunities. After the first run, the Tasks appear in nobody's task list and show "Automated Process" as owner. What is the cause, and how do you fix it?
Show answer
A scheduled flow runs as the Automated Process user, and the Tasks inherited that user as owner because the flow never set OwnerId. Fix it by looking up the Opportunity owner (for example with Get Records or by using the record's OwnerId from the scheduled record) and assigning it to the Task's OwnerId in the Create Records element.
Exercise
You build an autolaunched flow that a customer-facing screen flow calls through Subflow. The autolaunched flow reads Contract records that most users shouldn't see. Which "How to Run the Flow" option would you start with, and what is the risk of the other extreme?
Show answer
Start with System Context with Sharing, which respects what the user can see, and only move to System Context without Sharing if the flow truly needs access beyond the user's. Without Sharing grants access to all records, so a user could indirectly see or change data they have no right to reach through this flow.