Flow: How To Launch Your Flows And In What Context

If you have read through the article about different types of flows, the next question would be how each type of flow can be run, and in what context.

Summary

Flow typeLaunch methodrun CONTEXT
Screen Flow– Lightning Page
– Button
– Action
– Depends on how the flow is launched
– Always in system with sharing
– Always in system without sharing
Autolaunched Flow– Lightning Page
– Button
– Action
– With Process Builder
– Depends on how the flow is launched
– Always in system with sharing
– Always in system without sharing
Record-Triggered Flow– Record Changes– System
Schedule-Triggered Flow– Schedule Met– System
Platform Event-Triggered Flow– Platform Event Received– System

As the trigger for last three types can be configured directly in flow, in this article we will focus on how to launch flow in Lightning Page, Button, Action, and in Process Builder.

Launch On Lightning Page – Will Run In User Context

launch context - lightning page -user context

You can access the Lightning Page by going to Setup > Lightning App Builder, or simply go to a record of that object > Click on the gear > Edit Page.

launch context - lightning page -user context

Look for the flow component, and drag it to where you want.

launch context - lightning page -user context

When clicking on the placed component, you can configure the details of the flow, including the input variables and display layout.

Launch With Button – Will Run In User Context

Go to Object Manager and the object where you want to launch the flow > Buttons, Links, and Actions > New Button or Link on the upper right.

launch context - button -user context

Choose detail page button and paste in the flow url. If you want to assign the input variables, type “?[Variable name] = xxxx“. Note that if you have two input variables, use “&” to connect them.

Example: /flow/Main_Flow_2_Task?variableA=”Yes”&variableB=”No”

Launch With Action – Will Run In User Context

Go to Object Manager and the object where you want to launch the flow > Buttons, Links, and Actions > New Action on the upper right.

launch context - action -user context

Please note that you cannot paste in any other input variables except from ***recordId in actions.

Launch In Process Builder – Will Run In System Context

In the actions, click Add Action > Choose Flows as Action Type > Choose the flow you want to launch and configure the input variables below. Please note that only active autolaunched flow can be called from Process Builder.

launch context - process builder -system context

What Is Context?

Think about it as “Who requests the actions to run”. Take withdrawing money from your bank account for example, for yourself you can withdraw as much as you want, but for a stranger they can get nothing (Hopefully!). You and the stranger are the different contexts here, and the result of actions will differ because you have different permissions.

It is the same in Salesforce. There are currently two context – system and user. System is like the super admin, so it can by pass any object or field permissions or sharing rules, while user context is restricted to the access of that current user who calls the action. However validation rules cannot be bypassed even in system context.

Let’s look at an example to make it clearer. There are two flows to update a case, flow A runs in system context and flow B in user context. Lulu is an user without permission to Case object. In this case, when Lulu triggers flow A, the case can be updated, but not when Lulu triggers flow B.
However, if there is a validation rule says “Lulu cannot edit any cases!” (Poor Lulu), then none of the flows will work.

How Can I Change The Context?

As mentioned above, the flows the are launched by Lightning Page, Buttons, and Actions are run in user context, and since Process Builder always runs in system context, the flows that are launched by PB is also in system context.

However, this is only true if you set the flows to run on default mode, which is “Depends on How Flow is Launched

To change the default, after you save the flow, click the gear on the upper left.

Click Show Advanced > How to Run the Flow, then you have two extra options – System Context with or without sharing.

launch context - change the context

Check this table to learn the difference about the three:


Context Type
Can Flow access:
RECORDS THAT USER HAS NO ACCESS

FIELDS THAT USER HAS NO ACCESS

OBJECTS THAT USER HAS NO ACCESS
User Context
System Context With Sharing
System Context Without Sharing

Official Salesforce Help Article On Flow Context

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments