Invoke Apex logic from a Salesforce Flow using an invocable method to bridge declarative and programmatic 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

  1. Create an Apex class with a public static method annotated with @InvocableMethod(label='My Action' description='...' category='My Category') so it appears as an action in Flow Builder
  2. Define input and output using inner classes annotated with @InvocableVariable on each field — primitive types and SObject references are supported; wrap parameters in a List<InputClass> to support bulk invocation from Flow
  3. Implement the method to process the full list of inputs at once (bulkified) — Flow may call the method with multiple records when used in a record-triggered flow that processes many records
  4. Return a List<OutputClass> of the same length as the input list; each output element maps back to the corresponding input record in Flow
  5. In Flow Builder, add an Action element and search for the method by its label; map Flow variables to the input fields and capture output fields into Flow variables for downstream use
  6. Test by running the Flow in debug mode and inspecting the Apex debug log to verify the invocable method received the expected inputs and returned correct outputs

Known gotchas

Related routes

Expose Apex logic to Salesforce Flow as an invocable method with typed input and output collections
developer.salesforce.com · 6 steps · unrated
Use Salesforce Apex to implement a Flow invocable action with typed input and output variables callable from declarative automation
developer.salesforce.com · 6 steps · unrated
Invoke a Salesforce autolaunched Flow via the REST Actions API
salesforce.com · 6 steps · unrated

Give your agent this knowledge — and 15,500+ 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?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans