Invoking Apex
You can run Apex code with triggers, or asynchronously, or as SOAP or REST web services.
-
An anonymous block is Apex code that doesn’t get stored in the metadata, but that you can compile and execute.
-
Apex can be invoked by using triggers. Apex triggers enable you to perform custom actions before or after changes to Salesforce records, such as insertions, updates, or deletions.
-
Apex offers multiple ways for running your Apex code asynchronously. Choose the asynchronous Apex feature that best suits your needs.
-
Exposing Apex Methods as SOAP Web Services
You can expose your Apex methods as SOAP web services so that external applications can access your code and your application.
-
Exposing Apex Classes as REST Web Services
You can expose your Apex classes and methods so that external applications can access your code and your application through the REST architecture.
-
You can use email services to process the contents, headers, and attachments of inbound email. For example, you can create an email service that automatically creates contact records based on contact information in messages.
-
For every email the Apex email service domain receives, Salesforce creates a separate InboundEmail object that contains the contents and attachments of that email. You can use Apex classes that implement the
Messaging.InboundEmailHandlerinterface to handle an inbound email message. Using thehandleInboundEmailmethod in that class, you can access an InboundEmail object to retrieve the contents, headers, and attachments of inbound email messages, as well as perform many functions. -
In addition to giving developers the ability to add business logic to Salesforce system events such as button clicks and related record updates, Apex can also be used to provide custom logic for Visualforce pages through custom Visualforce controllers and controller extensions.
-
Use JavaScript remoting in Visualforce to call methods in Apex controllers from JavaScript. Create pages with complex, dynamic behavior that isn’t possible with the standard Visualforce AJAX components.
-
The AJAX toolkit includes built-in support for invoking Apex through anonymous blocks or public
webservicemethods.