CRT-450 Exam QuestionsBrowse all questions from this exam

CRT-450 Exam - Question 266


A developer wrote an Apex method to update a list of Contacts and wants to make it available for use by Lightning web components.

Which annotation should a developer add to the Apex method to archive this?

Show Answer
Correct Answer: BD

To make an Apex method available for use by Lightning web components, it should be annotated with @AuraEnabled. The @AuraEnabled annotation allows the method to be called directly from JavaScript in Lightning Components, including both Aura components and Lightning web components. Other annotations such as @RemoteAction are more suited for Visualforce pages and should not be used in this context.

Discussion

5 comments
Sign in to comment
Cindy_HrOption: B
Oct 2, 2023

The correct answer is B. Imperative apex method call needs to be anotaded with @AuraEnabled.

BruceParkOption: B
Jul 24, 2023

Why not B?

SanjeevOnForceOption: B
Nov 2, 2023

Its B as (cacheable=true) is not required to achieve the request. However, can be added if needed.

SS1121Option: D
Jun 17, 2024

https://developer.salesforce.com/docs/platform/lwc/guide/apex-wire-method.html

Neel_sehgalOption: B
Jul 1, 2024

No, you cannot perform update operations in an @AuraEnabled(cacheable=true) method. The @AuraEnabled(cacheable=true) annotation is used to indicate that the method's results can be cached on the client side for performance optimization. This implies that the method must be idempotent and should not change any data. It should be used for read-only operations. To perform update operations, you should use a standard @AuraEnabled method without the cacheable=true attribute. Here’s how you can do it: