Skip to content

Instantly share code, notes, and snippets.

Avatar

Pat McClellan patmcclellan

View GitHub Profile
View gist:86c2cb3fcc267887eac8ad3899be12b7
List<Account> accountList = [SELECT Id, Name, BillingState FROM Account LIMIT 3];
System.debug('accountList: ' + accountList);
/* output from the log— just what you picture for a list of SObjects
USER_DEBUG [2]|DEBUG|accountList: (
Account:{Id=0013t00001YbRqrAAF, Name=Edge Communications-top, BillingState=TX},
Account:{Id=0013t00001YbRqsAAF, Name=Burlington Textiles Corp of America-top, BillingState=NC},
Account:{Id=0013t00001YbRqtAAF, Name=Pyramid Construction Inc.-top}
)
@patmcclellan
patmcclellan / gist:d366744ac69ac6e59a821e70a754a796
Created Oct 1, 2020
Example of using Maps in Apex Trigger Handler
View gist:d366744ac69ac6e59a821e70a754a796
public with sharing class AccountTriggerHandler {
public static void handleBeforeInsert(List<Account> newAccounts){
for (Account a : newAccounts) {
if (a.Est_Annual_Sales__c >= 5000000) {
a.Priority__c = 'Highest';
} else if (a.Est_Annual_Sales__c >= 3000000) {
a.Priority__c = 'High';
} else if (a.Est_Annual_Sales__c >= 1000000) {
a.Priority__c = 'Standard';