Salesforce Platform Developer I (legacy) — Question 271
A Next Best Action strategy uses an Enhance Element that invokes an Apex method to determine a discount level for a Contact, based on a number of factors.
What is the correct definition of the Apex method?
Answer options
- A. @InvocableMethod global static List> getLevel(Listinput) { /*implementation*/ }
- B. @InvocableMethod global Recommendation getLevel(ContactWrapper input) { /*implementation*/ }
- C. @InvocableMethod global List> getLevel(Listinput) { /*implementation*/ }
- D. @InvocableMethod global static ListRecommendation getLevel(Listinput) { /*implementation*/ }
Correct answer: D
Explanation
The correct answer is D because it defines an Apex method that is both invocable and returns a static list of recommendations, which is essential for determining the discount level. Options A and C are incorrect as they do not return a List of Recommendation, while option B does not return a list at all and uses the wrong input parameter type.