You need to sign in to do that
Don't have an account?
Having troulbe with Entitlements
I am trying to implement entitlements and I have a few chunks of code that I found here on developerforce. The problem is one trigger that I found, I needed to clone it and change it so that it ran after update instead of after insert. I am using both blocks of code. One is 100% covered and the other (the one I changed) is 0% covered. It works perfectly and I would like to push it into our production org, but since it's a trigger I can't deploy it unless it is at least 1% covered. Can anyone help me out here?
Original Block of Code:
trigger completeFirstResponseCaseComment on CaseComment (after insert) { // Cannot be a portal user if (UserInfo.getUserType() == 'Standard'){ DateTime completionDate = System.now(); List<Id> caseIds = new List<Id>(); for (CaseComment cc : Trigger.new){ // Only public comments qualify if(cc.IsPublished == true) caseIds.add(cc.ParentId); } if (caseIds.isEmpty() == false){ List<Case> caseList = [Select c.Id, c.ContactId, c.Contact.Email, c.OwnerId, c.Status, c.EntitlementId, c.SlaStartDate, c.SlaExitDate From Case c Where c.Id IN :caseIds]; if (caseList.isEmpty() == false){ List<Id> updateCases = new List<Id>(); for (Case caseObj:caseList) { // consider an outbound email to the contact on the case a valid first response if ((caseObj.Status != 'Awaiting Customer Reply')&& (caseObj.EntitlementId != null)&& (caseObj.SlaStartDate <= completionDate)&& (caseObj.SlaStartDate != null)&& (caseObj.SlaExitDate == null)) updateCases.add(caseObj.Id); } if(updateCases.isEmpty() == false) milestoneUtils.completeMilestone(updateCases, 'First Response', completionDate); } } } }
Here is the code as I have altered it:
trigger completeFirstResponseCaseCommentUpdateToPublic on CaseComment (after update) { // Cannot be a portal user if (UserInfo.getUserType() == 'Standard'){ DateTime completionDate = System.now(); List<Id> caseIds = new List<Id>(); for (CaseComment cc : Trigger.new){ // Only public comments qualify if(cc.IsPublished == true) caseIds.add(cc.ParentId); } for (CaseComment cc : Trigger.old){ // Only public comments qualify if(cc.IsPublished == true) caseIds.add(cc.ParentId); } if (caseIds.isEmpty() == false){ List<Case> caseList = [Select c.Id, c.ContactId, c.Contact.Email, c.OwnerId, c.Status, c.EntitlementId, c.SlaStartDate, c.SlaExitDate From Case c Where c.Id IN :caseIds]; if (caseList.isEmpty() == false){ List<Id> updateCases = new List<Id>(); for (Case caseObj:caseList) { // consider an outbound email to the contact on the case a valid first response if ((caseObj.Status != 'Awaiting Customer Reply')&& (caseObj.EntitlementId != null)&& (caseObj.SlaStartDate <= completionDate)&& (caseObj.SlaStartDate != null)&& (caseObj.SlaExitDate == null)) updateCases.add(caseObj.Id); } if(updateCases.isEmpty() == false) milestoneUtils.completeMilestone(updateCases, 'First Response', completionDate); } } } }