Sub topic 12
Who the flow runs as and what it can access
This chapter assumes you know how to start an autolaunched flow and how a schedule-triggered flow starts. It also assumes you know Salesforce permission sets, field-level security (FLS), and sharing rules. A flow can read and write only what its run context allows, so a flow that works in a debug run can still fail in production.
Two questions: which user, and which mode
Every flow run has two settings that decide its access:
- Running user: the identity that owns the run. It appears in fields such as Created By and Last Modified By.
- Run mode: whether the flow enforces that user's object permissions, FLS, and record sharing.
Who starts the run
| How the flow starts | Running user | Default behavior |
|---|---|---|
| Schedule-triggered flow | Automated Process user | System context. User permissions are not checked. |
| Autolaunched flow called from another flow | The calling flow's user | Inherits the caller's context. |
| Autolaunched flow called from Apex | The user running the Apex | User permissions apply unless the flow sets a system mode. |
| Autolaunched flow called from REST | The user behind the access token | User permissions apply unless the flow sets a system mode. |
The Automated Process user is a built-in user that Salesforce uses for background work. You cannot log in as it. Records that a scheduled flow creates or updates show it as the creator or last modifier. Do not build logic that assumes a human owner. Assign ownership explicitly if you need it.
Run mode on an autolaunched flow
You set run mode in the flow's settings. In metadata it is the runInMode field:
<runInMode>SystemModeWithoutSharing</runInMode>The three values behave as follows:
DefaultMode: runs in the context of the caller. If a user starts it, that user's permissions apply.SystemModeWithSharing: ignores object permissions and FLS but still enforces record sharing.SystemModeWithoutSharing: ignores all of them and sees every record.
Common errors
- Works in debug, fails in production. The debug run used your admin permissions. The real caller lacks access to an object or field. Test with a representative user, or set a system run mode on purpose.
- Field values come back empty. In user context, fields hidden by FLS are not returned, and no error is raised.
- Scheduled flow touches too much. System context ignores sharing, so the flow sees every record that matches its filter. Filter explicitly.
- Wrong owner on new records. The Automated Process user becomes the owner unless the flow sets
OwnerId.
Exercise
An autolaunched flow uses the default run mode. A sales user calls it through Apex, and it fails when it updates a field the user cannot edit. Give two ways to fix this, and name a risk of each.
Show answer
Grant the user edit access to the field through a permission set. The risk is that the user gets that access everywhere, not only in this flow. Or set the flow's run mode to a system mode. The risk is that the flow bypasses FLS, and sharing too if you choose SystemModeWithoutSharing, for every caller.