January 2015
Beginner to intermediate
302 pages
6h 56m
English
We'll talk about triggers more in a later chapter, but for now you just need to know that a trigger is code that is automatically executed whenever a record is operated upon (meaning inserted, updated, deleted, or undeleted). When you first start programming in Apex, it tends to be trigger-related. These are usually simple scenarios such as when an account phone is modified, update the phone for all of the contacts on that account. This is shown in the following code:
//This code has a potentially fatal flaw in it public static void updateContactAddresses(){ List<Contact> contactList = [ Select Id, Phone, AccountId, Account.Phone from Contact ]; for ( Contact c : contactQuery ){ c.Phone = c.Account.Phone; ...Read now
Unlock full access