The hands-on training is based on the default developer edition organization and has some customizations that must be done prior to starting with the rest of the exercises
Change the priority field on the case to only have High and Normal
Click Setup | Customize | Cases | Fields
Click Priority
Ciick Edit next to Low
Check Make this value the default for the master picklist
Click Save
Click Del next to Medium
Create a new Owner Comment Count field
Click Setup | Customize | Cases | Fields
Click New under Case Custom Fields & Relationships
Choose Number and click Next
Fill in the following information
Field Label
Owner Comment Count
Length
18
Decimal Places
0
Field Name
Owner_Comment_Count
Click Next
Click Next
Click Save
Remove all page layouts for Case except Case Layout
Click Setup | Customize | Cases | Page Layouts
Click Del next to Case (Marketing) Layout
Click Replace
Repeat B-C for Case (Sales) Layout
Repeat B-C for Case (Support) Layout
Add Business Hours to the case layout
Click Setup | Customize | Cases | Page Layouts
Click Edit next to Case Layout
Drag the Business Hours field onto the page layout
Click Save
Add a new breach email template
Click Setup | Communication Templates | Email Templates
Click New Template
Choose Text
Click Next
Fill in the following information
Folder
Unfiled Public Email Templates
Template Name
Support: Case has breached
Unique Name
Support_Case_has_breached
Subject
Case {!Case.CaseNumber} has breached SLA
Body
Case Number: {!Case.CaseNumber}
Subject: {!Case.Subject}
Click Save
Create the CaseCommentCount trigger
Click Setup | Develop | Apex Triggers
Click Developer Console
Click File | New | Apex Trigger
Fill in the following information and click Submit
Name
CaseCommentCount
sObject
Case
Replace the contents with the following
trigger CaseCommentCount on CaseComment (after insert, after delete) {
Set<Id> ownerIds = new Set<Id>();
Set<Id> caseIds = new Set<Id>();
Map<Id, Integer> commentCount = new Map<Id, Integer>();
List<CaseComment> comments = (Trigger.isInsert) ?
Trigger.new : Trigger.old;
for (CaseComment cc : comments) {
caseIds.add(cc.ParentId);
commentCount.put(cc.ParentId, 0);
}
for (Case c : [select OwnerId from Case where Id in :caseIds]) {
ownerIds.add(c.OwnerId);
}
for (CaseComment cc : [
select CreatedById,
ParentId
from CaseComment
where ParentId in :caseIds and
CreatedById in :ownerIds
]) {
commentCount.put(cc.ParentId,
commentCount.get(cc.ParentId) + 1
);
}
List<Case> casesToUpdate = new List<Case>();
for (Id id : commentCount.keySet()) {
casesToUpdate.add(new Case(
Id = id,
Owner_Comment_Count__c = commentCount.get(id)
));
}
update casesToUpdate;
}