runApex() for Salesforce Classic

Executes an Apex method from an Apex class that’s exposed in Salesforce.

NameTypeDescription
apexClassstringSpecifies the Apex class of the method to execute.
methodNamestringSpecifies the method to execute.
methodParamsstringSpecifies the method parameters to pass. The string must include field value pairs and be formatted as a valid query string. For example:name=acme&phone=(212) 555-5555.
callbackfunctionJavaScript method executed when the API method call is completed.
  1. An administrator creates an Apex class and Apex method:

  2. In the location where you’ve created the Apex class and method in Salesforce, click Generate WSDL to expose the method and class so that a third-party softphone can call it.

  3. Add your code to the softphone:

  4. Output is returned. In this example, one account named, Acme, was found:

NameTypeDescription
resultstringReturns 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 was executed.
errorstringIf the API call was successful, this variable is undefined. If the API call failed, this variable returns an error message.