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

Pulling the trigger


By now, you have hopefully logged in to your Developer Edition of the Salesforce1 Platform and created some sample data. You might have noticed that in order to create a new record, you must fill out any required fields. You might have already played with the workflow feature we mentioned earlier, which can modify a record upon save. If you're really eager, you can even experiment with validation rules, which can prevent a record from being saved if it does not meet your preset criteria. All of these various features make the simple act of saving a record a very complex process. To make things more complex, triggers are executed in two places in this process.

The first place in the process where a trigger is executed occurs before a record is committed to the database. Triggers that execute at this time are commonly referred to as before triggers. They are used to intercept a record that is being sent to the database. This is the perfect time to validate the record against...