Use Salesforce Apex to implement a Flow invocable action with typed input and output variables callable from declarative automation
domain: developer.salesforce.com · 6 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗
In-depth guide
Salesforce Bulk API 2.0 limits — the full failure-mode walkthrough related to developer.salesforce.com, checked against official docs, with linked verified routes.
Steps
Create a global Apex class with a static method annotated @InvocableMethod and provide a label and description for the Flow UI
Define an inner class for inputs annotated with @InvocableVariable for each field with required=true where appropriate
Define a separate inner class for outputs also using @InvocableVariable so Flow can map results to variables after the action
The invocable method must accept a List of the input class and return a List of the output class to support bulk Flow contexts
Write test coverage for the invocable method by calling it directly with a constructed list of input objects
After deployment the action appears in the Flow builder Action element picker under your label name
Known gotchas
The method signature must accept a List even if logically only one record is processed; a non-List parameter type causes a deployment error
If the Flow is triggered in bulk context (e.g., a Record-Triggered Flow on a batch save), the List passed to the invocable method contains multiple inputs; code that assumes index 0 only will fail silently for subsequent records
Complex types like Map or custom Apex object hierarchies cannot be used as InvocableVariable types; only primitive types and supported sObject types are allowed
Give your agent this knowledge — and 15,600+ more routes
One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp
Need this verified for your stack — or a route we don't have yet?