PDI · Question #125
A Salesforce Administrator is creating a record-triggered flow. When certain criteria are met, the flow must call an Apex method to execute complex validation involving several types of objects. When
The correct answer is C. @InvocableMethod. To enable an Apex method to be called from a Salesforce Flow, it must be annotated with @InvocableMethod.
Question
A Salesforce Administrator is creating a record-triggered flow. When certain criteria are met, the flow must call an Apex method to execute complex validation involving several types of objects. When creating the Apex method, which annotation should a developer use to ensure the method Can be used within the flow?
Options
- A@future
- B@RemoteAction
- C@InvocableMethod
- D@AuraEnaled
How the community answered
(50 responses)- A6% (3)
- B2% (1)
- C90% (45)
- D2% (1)
Why each option
To enable an Apex method to be called from a Salesforce Flow, it must be annotated with `@InvocableMethod`.
`@future` methods execute asynchronously and are typically used for long-running operations that shouldn't block the main transaction, not for making a method callable from a flow directly.
`@RemoteAction` is used for exposing Apex methods as JavaScript Remoting methods to be called from Visualforce pages, not for use within Flows.
The `@InvocableMethod` annotation exposes an Apex method as an invocable action, allowing it to be called directly from Salesforce Flows, Process Builders, and REST APIs. This annotation ensures the method can receive inputs from the flow and execute complex logic.
`@AuraEnabled` is used to expose Apex methods to Lightning web components or Aura components, not for direct invocation from Flows.
Concept tested: Invocable Apex methods for Salesforce Flows
Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_annotation_InvocableMethod.htm
Topics
Community Discussion
No community discussion yet for this question.