runApex() for Lightning Experience
Executes an Apex method from an Apex class that’s exposed in Salesforce. This method is available in API version 38.0 or later.
Pass a single args object with the following properties.
| Name | Type | Description |
|---|---|---|
apexClass | string | Specifies the Apex class of the method to execute. |
methodName | string | Specifies the method to execute. |
methodParams | string | Specifies the method parameters to pass. The string must include field value pairs formatted as a valid query string. If the Apex method doesn’t take any parameters, specify methodParams as none or an empty object, {}. |
callback | function | JavaScript method called upon completion of the method. Optional. |
Example methodParams value:
-
In Setup, create an Apex class and Apex method.
-
In Setup, click Generate from WSDL to expose the method and class so that a third-party softphone can call it.
-
Add your code to the softphone:
-
Output is returned. In this example, one account named Acme was found:
| Name | Type | Description |
|---|---|---|
success | boolean | Returns true if the API method call was invoked successfully, false otherwise. |
returnValue | object | A JavaScript object containing the result from executing the method from the specified Apex class. No specific format is returned. The format is determined by the value from the method that executed. |
errors | array | If the API call was successful, this variable is null. If the API call failed, this variable returns an array of error messages. |
Example returnValue: