You need to sign in to do that
Don't have an account?
Ido Greenbaum 10
Apex tests for custom 'CaseEmailExtension'
Hi Commnunity,
I was able to complete a customized 'CaseEmailExtension' code solution in my SandBox, which queries a Case EmailMessages, and output these to a VisualForce Email Template.
I am struggling with adding the Tests, and would be glad to receive some help.
Below is the VisualForce Component:
Thank you.
I was able to complete a customized 'CaseEmailExtension' code solution in my SandBox, which queries a Case EmailMessages, and output these to a VisualForce Email Template.
I am struggling with adding the Tests, and would be glad to receive some help.
Below is the VisualForce Component:
<apex:component controller="CaseEmailExtension" access="global"> <apex:attribute name="caseId" type="Id" description="Case Id" assignTo="{!csId}"/> <apex:repeat value="{!sortEmails}" var="email"> <apex:outputText value="{0,date,dd'.'MM'.'yyyy HH:mm:ss z}" style="font-weight:bold;font-style:italic;font-size:15px;float:left"> <br><apex:param value="{!email.MessageDate}" /></br></apex:outputText> <br>From: <apex:outputText value="{!email.FromAddress}"/></br> To: <apex:outputText value="{!email.ToAddress}"/> <apex:outputPanel rendered="{!email.CcAddress!=null}" > <br>Cc: <apex:outputText value="{!email.CcAddress}"/></br></apex:outputPanel> <apex:outputPanel rendered="{!email.BccAddress!=null}" > Bcc: <apex:outputText value="{!email.BccAddress}"/></apex:outputPanel> <br>Subject: <apex:outputText value="{!email.Subject}"/></br> <br><apex:outputText value="{!email.HtmlBody}" escape="false"/></br> ____________________________________________ </apex:repeat> </apex:component>And the Apex Class:
public with sharing class CaseEmailExtension { public ID csId {get; set;} // comes from assignTo on component public CaseEmailExtension() { } private final Case currentCase; public CaseEmailExtension(ApexPages.StandardController currentcase) { this.currentCase = (Case)currentcase.getRecord(); } public List<EmailMessage> getSortEmails(){ String contactEmail = [SELECT Id, ContactEmail FROM Case where Id=:csId].get(0).ContactEmail; contactEmail = '%'+contactEmail+'%'; return this.csId == null ? new List<EmailMessage>() // handles UI preview use case : [SELECT Id, FromAddress, ToAddress, BCCAddress, CcAddress, MessageDate, Subject, Incoming, HtmlBody, CreatedBy.Name from EmailMessage where ParentId =: this.csId AND(FromAddress LIKE :contactEmail OR ToAddress LIKE :contactEmail OR BCCAddress LIKE :contactEmail OR CcAddress LIKE :contactEmail) order by MessageDate DESC ]; } }
Thank you.
Use below code,
Hope this will help you.
Mark Best ANSWER if its works for you,
Thanks
karthik
All Answers
Use below code,
Hope this will help you.
Mark Best ANSWER if its works for you,
Thanks
karthik