1

Email Template:

    <messaging:emailTemplate subject="Milestone:{!relatedTo.MilestoneType.Name} - yet to complete" recipientType="Contact" relatedToType="CaseMilestone">
<messaging:htmlEmailBody ><br/><br/><br/>
*** Milestone Warning **** <br/><br/>
<c:MSCaseDetails MScaseId="{!relatedTo.CaseId}"/><br/>
Milestone Name: {!relatedTo.MilestoneType.Name}<br/>
Target Date: {!relatedTo.TargetDate}<br/>
Elapsed Time (Mins): {!relatedTo.ElapsedTimeInMins}<br/>
Time Remaining (Mins): {!relatedTo.TimeRemainingInMins}<br/><br/>
Case reference: https://cs42.salesforce.com/{!relatedTo.CaseId} <br/><br/><br/>
Kindly remember to complete the milestone before it expires.<br/><br/><br/>
</messaging:htmlEmailBody>
</messaging:emailTemplate>

VF Componenet:

​<apex:component controller="FindCaseDetails" access="global">      
<apex:attribute name="MScaseId" description="testing" type="Id" required="required" assignTo="{!caseId}"/>
Case#: <apex:outputField value="{!CaseDetails.CaseNumber}"/> <br/>    
Assigned To: <apex:outputField value="{!CaseDetails.Owner.Name}"/>

Contoller:

    public class FindCaseDetails {
    public static Case cs;
    public static Id caseId {get;set;}

    public FindCaseDetails() {
    }

    public Case getCaseDetails() {
        cs  = [select CaseNumber, Owner.Name from Case where id =:caseId];
        return cs;
    }

}

Here is my setup to trigger a warning for a case milestone. I'm getting the alert by it has no MileStone Information in it. Alert I received upon milestoine warning is:

Subject: Sandbox: Milestone: - yet to complete

Email Body: *** Milestone Warning ****

Case#:00076658 Assigned To:New Cases Milestone Name: Target Date: Elapsed Time (Mins): Time Remaining (Mins):

Case reference: https://cs42.salesforce.com/

Kindly remember to complete the milestone before it expires.

Someone please let me know, why the alert is not displaying the milestone details during the actual execution.

1 Answer 1

0

Your template is written with the relatedTo on CaseMilestone, yet your component and it's query are dependent on Case. <c:MSCaseDetails MScaseId="{!relatedTo.CaseId}. It seems to me that everything you're doing is related to the CaseId first and then second the milestone the Case is passing through. Your code isn't consistent in the way it processes those. The Milestone is a child of Case.

I don't see any standard controllers being used in what you've posted, so I'm not certain what's supposed to call your class that gets the details. If the controller that runs your visualforce page that calls the template runs on Case as opposed to Milestone, that should tell you a lot on how to resolve your issue. You can't point to both, as in do you have a milestone Id? I somewhat suspect that you may not.

1
  • Thanks for the idea. I'm using this email template to creation a workflow action when a milestone is completed/violated. So, always this will be used in CaseMileStone Alerts. Hence I thought of using the template relatedto=CaseMileStone object. However, I just noticed the MileStone Action is for Case object, so the template never get a CaseMilestone ID, thats why it's returning nothing.
    – AKK
    Jun 24, 2016 at 16:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .