PDI · Question #145
Einstein Next Best Action Is configured at Universal Containers to display recommendations to internal users on the Account detail page. If the recommendation is approved, a new opportunity record…
The correct answer is B. The method must use the @Future annotation. D. The method must be defined as static. E. The method must be defined as public. To perform an asynchronous callout from an Apex method invoked by Einstein Next Best Action upon recommendation rejection, the method must be defined as public, static, and annotated with @Future.
Question
Einstein Next Best Action Is configured at Universal Containers to display recommendations to internal users on the Account detail page. If the recommendation is approved, a new opportunity record and task should be generated. If the recommendation is rejected, an Apex method must be executed to perform a callout to an external system. Which three factors should a developer keep Hi mind when implementing the Apex method? Choose 3 answers
Options
- AThe method must use the @AuraEnabled annotation.
- BThe method must use the @Future annotation.
- CThe method must use the @invocableMethod annotation.
- DThe method must be defined as static.
- EThe method must be defined as public.
How the community answered
(67 responses)- A16% (11)
- B76% (51)
- C7% (5)
Why each option
To perform an asynchronous callout from an Apex method invoked by Einstein Next Best Action upon recommendation rejection, the method must be defined as public, static, and annotated with `@Future`.
The `@AuraEnabled` annotation is used for exposing Apex methods to Lightning web components or Aura components, not directly for invocation from Einstein Next Best Action for a callout.
The `@Future` annotation is required for Apex methods that perform callouts to external systems, as callouts cannot be made synchronously from within a transaction that initiated from a UI action or declarative process.
The `@InvocableMethod` annotation is used to make an Apex method invokable from a Flow or Process Builder, but for the actual callout itself, the `@Future` annotation is specifically needed for asynchronous execution.
Apex methods intended to be invoked by declarative tools like Einstein Next Best Action (which often uses flows/processes) must be defined as static.
Apex methods intended to be invoked by declarative tools must be defined as public to ensure they are accessible from the invoking context.
Concept tested: Apex callouts, @future, static and public methods
Source: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_callouts_future_methods.htm
Topics
Community Discussion
No community discussion yet for this question.