Skip to content

Instantly share code, notes, and snippets.

View artminor's full-sized avatar
🎯
Focusing

Jun Chen artminor

🎯
Focusing
  • https://www.freecodecamp.org/artminor
  • DC / NYC / Remote
View GitHub Profile
trigger LeadTrigger on Lead (After Update) {
Map<Id, Lead> leadsToUpdate = new Map<Id, Lead>();
List<Competitor__mdt> competitorRecords = [Select Label from Competitor__mdt];//Retrieve our Custom Metadata Records
List<String> competitorNames = new List<String>();//Instantiate an empty list to hold the names of our competitors
for(Competitor__mdt record : competitorRecords){//Loop through the Custom Metadata records our query returned
competitorNames.add(record.Label);//Add them to our empty list
}
for(Integer i = 0 ; i < trigger.new.size() ; i++){
@isTest (seeAllData = true)
public class SOQLqueries {
static testMethod void relationshipQueries(){
//Child-to-Parent queries are easy. Simply use the API Name of the lookup field to the parent object
//and use dot notation to specify the field on that object you want
List<Contact> conAccts = [SELECT FirstName, LastName, Account.Name FROM Contact];
//FIX ME! Use a query with a WHERE filter to only return Contacts from the Account named 'sForce'
@isTest
public class Collections {
static testMethod void Lists(){
//LISTS ARE AN ORDERED COLLECTION OF DATA
//How to instantiate a List with some pre-defined values
String someword = 'thread';
List<String> threeStrings = new List<String>{'rope', 'twine', someword};
//Lists have methods that allow us to evaluate or manipulate them