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 RecipeHandler2 { | |
// Week 6 homework: Exception Testing | |
public static void throwException(List<Recipe__c> exceptionRecipes){ | |
for (Recipe__c r : exceptionRecipes){ | |
if (r.Name == null || r.Active_Time__c == null || r.Description__c == null || r.Active_Time_Units__c == null || r.Servings__c == null){ | |
r.addError('One of the key ingredients is null!'); | |
} | |
} | |
} |
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 RecipeHandler { | |
public static void checkDraft(List<Recipe__c> draftRecipes) { | |
for (Recipe__c r : draftRecipes){ | |
if (r.Name == null || r.Active_Time__c == null || r.Description__c == null || r.Active_Time_Units__c == null || r.Servings__c == null){ | |
r.Draft__c = true; | |
} | |
} | |
} |
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
@isTest | |
private class RecipeHandler_Test { | |
@testSetup | |
static void dataCreation(){ | |
// Create data for testing Draft recipes | |
List <Recipe__c> draftRecipes = new List<Recipe__c>(); | |
for(integer i=0; i < 4; i++){ | |
Recipe__c r = new Recipe__c( | |
Name = 'Draft Recipe ' + i, |
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 RecipeHandler { | |
public static void checkDraft(List<Recipe__c> draftRecipes) { | |
for (Recipe__c r : draftRecipes){ | |
if (r.Name == null || r.Active_Time__c == null || r.Description__c == null || r.Active_Time_Units__c == null || r.Servings__c == null){ | |
r.Draft__c = true; | |
} | |
} | |
} |
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
<messaging:emailTemplate recipientType="User" | |
relatedToType="Case" | |
subject=" A New Case for the Communications Team Has Been Created: {!relatedTo.CaseNumber}" | |
replyTo="dhasupport@utah.gov" > | |
<messaging:htmlEmailBody > | |
<p>A new case for the Communications team has been created via the self-service web form (Hazel).</p> | |
<br/>Contact Name: {!relatedTo.Contact.Full_Name__c} | |
<br/>Subject: {!relatedTo.Subject} |
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
<apex:component controller="getCaseSysChanges" access="global"> | |
<apex:attribute name="currentCaseId" type="Id" description="Id of the case" assignTo="{!caseId}"/> | |
<table border = "2" cellspacing = "5"> | |
<tr> | |
<td><b>Sys Change Number</b></td> | |
<td><b>Type</b></td> | |
<td><b>Due Date</b></td> | |
<td><b>Description</b></td> | |
</tr> | |
<apex:repeat value="{!sysChanges}" var="sc"> |
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 class getCaseSysChanges { | |
public Id caseId {get;set;} | |
public List<System_Change__c> getSysChanges() | |
{ | |
List<System_Change__c> sysChanges; | |
sysChanges = [SELECT Name, Type_of_Change__c, Target_Completion_Date__c, Description_of_Change__c FROM System_Change__c WHERE | |
RecordType.DeveloperName ='MarCom_Secondary_Sys_Change' | |
AND Case__r.Id =: caseId]; | |
return sysChanges; | |
} |
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
trigger LeadTrigger on Lead (after insert, after update) { | |
switch on Trigger.operationType { | |
when AFTER_INSERT{ | |
LeadHandler.handleAfterInsert(trigger.new); | |
} | |
when AFTER_UPDATE{ | |
LeadHandler.handleAfterUpdate(trigger.new, trigger.oldMap); | |
} | |
} |
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 LeadHandler { | |
public static void handleAfterInsert(List<Lead> newLeads){ | |
List<Task> newTasks = new List<Task>(); | |
for (Lead l : newLeads){ | |
Task t = new Task(); | |
t.WhoId = l.Id; | |
switch on l.ProductInterest__c{ | |
when 'Cookbook Authorship'{ | |
t.Subject = 'Follow up About Cookbook Authorship'; |
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 class WeekTwoHomework { | |
// method (a) | |
public static void showAccNames(){ | |
integer i=0; | |
for (Contact c : [SELECT Id, Account.Name, Account.Industry FROM Contact]){ | |
i++; | |
System.debug ('Name of Account # ' + i + ' is ' + c.Account.Name); | |
} | |
} |
NewerOlder