This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//get a Contact | |
Contact c = [ | |
SELECT Id, Name, AccountId, Account.Name, Email, Phone | |
FROM Contact | |
LIMIT 1 | |
]; | |
// METHOD SIGNATURE | |
// public static String serializePretty(Object objectToSerialize, Boolean suppressApexObjectNulls) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Let's look at the method signature for newInstance() | |
* public static Datetime newInstance(Integer year, Integer month, Integer day, Integer hour, Integer minute, Integer second) | |
* | |
* it says right there that it's a static method, so we invoke it by using the Class name | |
* | |
*/ | |
Datetime appointment = Datetime.newInstance(2022,10,29,11,15,0); | |
Datetime nextWeekAppt = appointment.addDays(7); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'; |