Salesforce Flows: Key Considerations for InvocableVariable
Ever wondered how to make your Apex variables play nicely with Salesforce Flows? The @InvocableVariable annotation is your key! But before you start, here are some crucial considerations to keep in mind:
By keeping these points in mind, you’ll be well on your way to leveraging the full power of
@InvocableVariablefor robust and dynamic Salesforce Flows!
1. Exclusivity is Key
Think of @InvocableVariable as a VIP pass – it doesn't like to share! You cannot use other annotations alongside it. It wants to be the star of the show.
2. Accessibility Matters
Only variables with global or public access modifiers can be invocable. This ensures your Flows can "see" and interact with them.
3. What NOT to Use
Avoid using these types of variables with @InvocableVariable:
- Non-member variables: Static or local variables are out.
- Properties: Getters and setters aren’t supported here.
- Final variables: Once set, final variables can’t be changed, which defeats the purpose of an invocable variable.
- Protected or private variables: These aren’t accessible to Flows.
Get Mr. Riyas’s stories in your inbox
Join Medium for free to get updates from this writer.
4. Supported Data Types
Your invocable variables need to speak Flow’s language! The data types must be one of the following:
- Primitives: Any primitive data type except
Object. - sObjects: Both generic
sObjectand specific sObjects (likeAccountorContact). - Collections:
ListorListofListof primitives, sObjects, or objects created from Apex classes.
5. Name Matching (Case-Sensitive!)
This is crucial for seamless integration! The name of your invocable variable in Apex must exactly match the name you use in the Flow. Remember, it’s case-sensitive!
6. Managed Package Considerations
If you’re working with managed packages, keep these points in mind:
Publicinvocable variables: Can only be set in Flows and Processes within the same managed package.Globalinvocable variables: These are the most flexible! They can be set anywhere in the subscriber org and are the only invocable variables that appear in Flow Builder and Process Builder for subscribers.






