Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Exam Platform Developer II Topic 4 Question 115 Discussion

Actual exam question for Salesforce's Platform Developer II exam
Question #: 115
Topic #: 4
[All Platform Developer II Questions]

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

Show Suggested Answer Hide Answer
Suggested Answer: A, B

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.


Lightning Web Components and Salesforce Data: Developer Documentation

@AuraEnabled Annotation: Apex Developer Guide

Contribute your Thoughts:

Alexia
2 days ago
I think we need to add @AuraEnabled {cacheable=true) to line 03.
upvoted 0 times
...
Jacob
3 days ago
I agree with Rebbecca. Removing the private modifier and adding public won't work because the method is still not @AuraEnabled.
upvoted 0 times
...
Rebbecca
7 days ago
A and D are the correct answers. The Apex method needs to be marked as @AuraEnabled and cacheable=true to be wired to the component.
upvoted 0 times
Junita
16 hours ago
A) Add @AuraEnabled {cacheable=true) to line 03.
upvoted 0 times
...
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77