O'Reilly logo

Mastering Application Development with Force.com by Kevin J. Poorman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Using the framework

Because the methods in the TriggerHandler class are ultimately invoked during an Apex trigger context, they have access to the trigger context variables such as Trigger.new and Trigger.old. Additionally, if the context supports it, you'll have access to Trigger.newMap and Trigger.oldMap. While you have access to these collections in the TriggerHandler class, you must cast them to typed collections. This is required because Apex actually returns a collection of generic sObjects rather than collections of sObject subclasses, such as Account, Opportunity and so on. With this in mind, it's a good idea to use the constructor of your trigger handler to set a few class level variables that are precast to the object your handler works ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required