Book Image

Learning Apex Programming

5 (1)
Book Image

Learning Apex Programming

5 (1)

Overview of this book

Table of Contents (17 chapters)
Learning Apex Programming
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Trigger happy


The simple definition of an Apex trigger is code that is executed when a record is saved. In reality though, triggers are much more complex than this. Triggers are programmatic event handlers for the Salesforce1 Platform (unlike workflow, which is declarative). As Apex is stored and executed on the Force.com servers, triggers only run server side, not client side. Accordingly, the only events that triggers can handle are Database Manipulation Language (DML) operations. The only DML operations on Salesforce1 Platform are insert, update, delete, and undelete. In the Force.com documentation, you might occasionally see references to a merge or clone operation; however, for the purposes of triggers, a merge operation is really a combination of the update and delete operations and a clone operation is merely an insert operation.

Note

It is possible to use Apex code to handle non-DML-related events such as the clicking of a button or selecting a value in a drop-down menu. For these...