What Kind of Info Can be Sent Into and Received From a Subflow?
- Primitive data types like text, number, Boolean, currency, date, date time, and picklist values
- Collections of primitive data types
- sObject collections
So What’s So Interesting About That?
Here’s what’s interesting:
Subflows, when receiving information from or or sending information to a calling flow, must have access modifiers on those variables to expose to the calling source (Other Flows, Visualforce, and Apex).
Calling Flows, however, do not need access modifiers on variables used to send information to or receive information from a Subflow. In other words, calling Flows can keep all of their variables Private.
What’s An Access Modifier?
Access modifiers define where the item can be viewed and used. For Flow variables the access modifiers are:
- The variable can be used only within the Flow
- Input only
- The value of the variable can be input into the Flow
- Output only
- The value of the variable can be received by a calling Flow
- Input and Output
- The value of the variable can be input into the Flow and is also available for a calling Flow to receive back
[As an aside, Apex access modifiers are slightly different: Private, Public, Global]
What Does This Mean?
- Items without access modifiers (Constants, Text Templates, and Formulas) can be used to pass values to a Subflow
- Variables without access modifiers can be used to receive values from a Subflow
- Only variables that need to be exposed to an external source need to have an access modifier other than Private
Using Constants, Text Templates, and Formulas
Using items that do not have access modifiers to set values for a Subflow sort of makes sense because when you call a Subflow you can simply type a value into the Source field, which would sort of be the same as using a Constant.
Keeping Subflows Easy To Use
When working with a single Subflow things are pretty straightforward: The Input and Output variables you see in the Target picklists will pertain to that Subflow only.
However, when a Subflow in turns uses other Subflows, the visible variables can start to get a little confusing. Variables that have been marked as Input because they are receiving information from another Subflow are now exposed to the original calling Flow. They don’t really need to be initialized by the calling Flow, yet there they are in the picklist when you click on the Target field.
Here is an example of a Subflow that has several Target variables:
If some of these variables can be marked Private the Target selection becomes much easier:
There you have it. Simplification. It’s a beautiful thing.