Combining Flow and Apex for business logic
How to expose Apex to Flow with @InvocableMethod and @InvocableVariable, why invocable actions take and return lists that line up with the flow's interviews, how flows start from Apex, and where to draw the line between the flow and the code.
Given a scenario, use declarative functionality and Apex together to automate business logic.
~7 min read · 7 practice questions ·
What the exam expects
- Make Apex available to Flow Builder as an Apex action with
@InvocableMethod, and pass structured inputs and outputs with@InvocableVariable. - Apply the invocable rules: static, public or global, one per class, one list parameter, a list result that matches the inputs in size and order.
- Predict how a record-triggered flow calls an Apex action for 200 records, and which limits the action shares.
- Start a flow from Apex with the
Flow.Interviewclass. - Given a scenario, decide which part of the logic stays in the flow and which moves to Apex.
Key terms: invocable method (an Apex method annotated @InvocableMethod that runs as an action); Apex action (the Action element in Flow Builder that calls it); invocable variable (a field of a request or response class annotated @InvocableVariable); flow interview (one running instance of a flow); bulkification (grouping many interviews' work into one operation).
Key facts
- Detail
- static, and public or global; outer class only
- Detail
- Only one
@InvocableMethod
- Detail
- Only
@Deprecatedcan accompany@InvocableMethod
- Detail
- At most one, and it is a list or a list of lists
- Detail
- Same size and order as the inputs
- Detail
- Needs access to the Apex class via profile or permission set
- Detail
- public or global members;
requireddefaults to false; name matches the flow, case-sensitive
- Detail
- Legacy; no bulk operations;
@InvocableMethodrecommended
- Detail
- All interviews in the transaction fail and roll back
Interview.start() limits- Detail
- Shared with the other operations in the transaction
Sources for this section (5)
- InvocableMethod Annotationdeveloper.salesforce.com (opens in a new tab)
- InvocableVariable Annotationdeveloper.salesforce.com (opens in a new tab)
- Let Flows Execute Apex Actionshelp.salesforce.com (opens in a new tab)
- Flow Bulkificationhelp.salesforce.com (opens in a new tab)
- How Flows Run in Transactionshelp.salesforce.com (opens in a new tab)
- Why must an invocable method return its results in the same order as its inputs?
- When do you need `@InvocableVariable`?
- What happens to the other interviews when one interview in a bulk flow transaction hits a governor limit?
- Why does a subscriber org's Flow Builder not show a public invocable method from a managed package?
The questions are free to read. Answers with their sources and self-grading are included with the pack.
Keep reading with the Platform Developer pack
- Core concepts
- Exam traps
- Worked scenario
The pack includes:
- All 21 lessons of the Platform Developer guide, with reading progress
- Interactive decision walks and step-by-step sequence steppers
- Inline practice questions and one-click topic practice (7 questions for this lesson)
- An official source cited for every claim
- An AI tutor that answers from the guide
- Unlimited timed practice exams