Blog

Blog » 2017 » October » 12 » APEX best practices
23:36
APEX best practices

Trigger

Trigger MileageTrigger on Mileage__c (before insert, before update) {
 Set<ID> ids = Trigger.newMap.keySet();
 List<User> c = [SELECT Id FROM user WHERE mileageid__c in :ids];
}
Apex

for ( List<contact> contacts : [SELECT Id FROM Contact] {
 for (Contact aContact : contacts) {
 //modify aContact
 }Database.update(contacts);
}