Learn the correct syntax to import an Apex method named updateAccounts from the AccountController class for use in a Lightning web component. Prepare for the Salesforce CRT-450 certification exam with this concise explanation.
Table of Contents
Question
Which code statement includes an Apex method named updateAccounts in the class AccountController for use in a Lightning web component?
A. import updateAccounts from ‘AccountController’;
B. import updateAccounts from ‘@salesforce/apex/AccountController.updateAccounts’;
C. import updateAccounts from ‘AccountController.updateAccounts’;
D. import updateAccounts from ‘@salesforce/apex/AccountController’;
Answer
B. import updateAccounts from ‘@salesforce/apex/AccountController.updateAccounts’;
Explanation
To include an Apex method in a Lightning web component, use the @salesforce/apex scoped module, followed by the Apex class name and method name separated by a dot. The correct syntax is:
import methodName from ‘@salesforce/apex/ApexClassName.methodName’;
Therefore, to import the updateAccounts method from the AccountController Apex class, the correct statement is:
import updateAccounts from '@salesforce/apex/AccountController.updateAccounts';
Salesforce Certified Platform Developer I CRT-450 certification exam practice question and answer (Q&A) dump with detail explanation and reference available free, helpful to pass the Salesforce Certified Platform Developer I CRT-450 exam and earn Salesforce Certified Platform Developer I CRT-450 certification.