Exam PDII Topic 3 Question 150 Discussion

Actual exam question for Salesforce's PDII exam
Question #: 150
Topic #: 3
A developer created a Lightning web component for the Account record page that displays the five most recently contacted Contacts for an Account. The Apex method, Contacts, returns a list of Contacts and will be wired to a property in the component.

Which two lines must change in the above code to make the Apex method able to be wired?
Choose 2 answers

Suggested Answer: A,B Vote an answer

To make an Apex method callable from a Lightning Web Component, you need to annotate the method with
@AuraEnabled and mark it as cacheable if it's only retrieving data without modifying it. Additionally, the method must be public to be accessible from the component.
Line 04: Needs @AuraEnabled(cacheable=true) to allow the method to be called from the Lightning Web Component and indicate that the method doesn't modify any data, making it suitable for caching.
Line 09: The method getFiveMostRecent should not be private because private methods cannot be called from a Lightning Web Component. Changing it to public (or default, which is equivalent to public within the same namespace) is required.
References:
Lightning Web Components and Salesforce Data: Developer Documentation
@AuraEnabled Annotation: Apex Developer Guide

by Dev2 at May 05, 2024, 05:39 PM

Comments

Chosen Answer:
This is a voting comment (?) , you can switch to a simple comment.
Switch to a voting comment New
Nick name: Submit Cancel
Dev2
2024-05-05 17:39:58
Wrong. Should use annotation on return method
upvoted 1 times
...
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

0
0
0
10