Everything About @salesforce/apex
Enhance your Salesforce development skills with @Salesforce/apex.
By importing Apex methods, you can call functions in your components through @wire or imperatively.
Here's how it works:
1. Import the Apex method using the syntax:
import apexMethodName from '@salesforce/apex/Namespace.Classname.apexMethodReference';
2. Use the @wire decorator to call the method and pass any required parameters in an object format:
@wire(apexMethodName, { apexMethodParams })
propertyOrFunction;
3. Remember to provide the necessary details:
- apexMethodName: The symbol that identifies the Apex method.
- apexMethodReference: The name of the Apex method to import.
- Classname: The name of the Apex class.
- Namespace: The namespace of your Salesforce organization.
Specify a namespace unless your organization uses the default namespace (c).
- apexMethodParams: An object that matches the parameters of the Apex method.
If a parameter value is null, the method is called.
If a parameter value is undefined, the method is not called.
Avoid overloading @AuraEnabled Apex methods.
Important:
To pass parameter values, make sure to use an object whose properties match the parameters of the Apex method.
Avoid passing a string directly; instead, use an object with a property containing the string value.
Note that maps are not supported for both imperative and wired Apex calls.
You must use the hardcoded data and error properties in the API to receive the results.
For more detailed information on how to leverage @Salesforce/apex in your Salesforce development, refer to our documentation.
Follow Us