Loading
Prepare for Email to Become the Default Login ExperienceRead More
Automate Your Business Processes with Salesforce Flow
Flow Run Context

Flow Run Context

Flows run in user context or system context. For a flow running in user context, the running user’s profile and permission sets determine the object permissions and field-level access of the flow. For a flow that runs in system context, the flow access is determined by whether the flow runs in system context with sharing or without sharing.

Required Editions

View supported editions.

The context that the flow runs in impacts what the following flow elements can do with Salesforce data:

  • Action
  • Create Records
  • Delete Records
  • Get Records
  • Subflow
  • Update Records
  • Any other flow element that accesses fields from a record

By default, a flow runs in user context or system context, depending on how the flow is launched. When a flow runs in system context, it runs in that context for all users, including users with the Guest User profile.

Flow Launch Method Default Context
Apex Depends on code
Experience Cloud site User
Embedded as a visual component inside a custom Aura component User
Embedded as a visual component inside a Visualforce page User
Custom button User
Custom link User
Direct link User
Flow action User
Lightning page User
Platform event System context without sharing
Process built in Process Builder System context without sharing
Record-triggered System context without sharing
Rest API User
Run from an Apex method of a custom Aura component controller Depends on code
Run from an Apex method of a Visualforce controller Depends on code
Schedule-triggered System context without sharing
Web tab User

Running User of a Flow

The running user of a flow is the user that launched the flow. The running user determines what a flow that runs in user context can do with Salesforce data.

For a flow running in user context, the running user’s profile and permission sets determine the object permissions and field-level access of the flow. When a flow attempts to create, read, edit, or delete Salesforce data, it enforces the running user’s permissions and field-level access. For example, if the running user doesn’t have the edit permission for the Account object, and the flow attempts to update account records, an error occurs. If the running user doesn’t have permission to edit the Rating field on the Account object, and the flow attempts to update that field, an error occurs.

Org-wide default settings, role hierarchies, sharing rules, manual sharing, teams, and territories also impact what data is accessible to flows that run in user context. If the org-wide default of the Opportunity object is private, and no opportunity records have been shared with the running user, the flow can’t read or edit any opportunity records.

By default, a flow in user context can inherit elevated permissions from a system-context caller, such as another flow or Apex. If a caller running in system context invokes your user-context flow, your flow also runs in system context. To guarantee that your flow always runs with the running user’s access level regardless of its caller, select User Context–Enforces User Permissions in the flow version properties. This option is available for screen and autolaunched flows on API version 68.0 and later. See Set Flow Run Context.

Limitations

  • Lightning components such as screen components and local actions always run in user context.
  • If the context depends on code, Apex uses the with sharing and without sharing keywords to specify whether to enforce org-wide default settings, role hierarchies, sharing rules, manual sharing, teams, and territories. A flow called by Apex always ignores object and field-level access permissions.
  • When a record-triggered flow, schedule-triggered flow, or process invokes an Apex invocable method from a class with inherited sharing, the method runs in system context with sharing. The flows and process run in system context without sharing.
  • If a process triggers the flow to launch, the user that triggered the process sometimes requires other permissions. For example, if a process launches a flow that attempts to save permission set license assignments without the running user having Assign Permission Sets, an error occurs.
  • A flow always runs in user context when it runs the Post to Chatter action.
  • The standard user context option doesn't prevent a flow from inheriting elevated permissions from a system-context caller, such as another flow or Apex. To enforce user-level access regardless of the caller, use the User Context–Enforces User Permissions option. This option requires API version 68.0 or later and is available for screen and autolaunched flows only.
  • Data Safety When Running Screen and Autolaunched Flows in System Context
    Screen flows and autolaunched flows without triggers can expose more data than intended. This potential issue primarily affects Experience Cloud sites accessed by external users. Configure proper user permissions for field-level and record-level security instead of running flows in system context. When system context is necessary, use only the minimum fields and records required.
  • Set Flow Run Context
    Override the default run context of a flow to control what data it can access. Run a flow in system context with or without sharing, or enforce user-level access regardless of the caller.
 
Loading
Salesforce Help | Article