• saas_ydu
  • NEWBIE
  • 5 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies

I would like to improve the Case Comment Template defined in our Cases / Support Settings.

It's a Visualforce Email Template, working well (including translations) but missing the "Last Case Comment" information.

 

I have tried a bunch of solution with no success until now. Can someone pinpoint what I am doing wrong ?

 

Here is my Apex Class:

public class findSaaSlastCaseComment {
    private final List<CaseComment> cComment;
    public Id caseId {get; set;}

    public findSaaSlastCaseComment() {
        cComment = [SELECT CommentBody FROM CaseComment WHERE ParentId = :caseId AND IsPublished = True ORDER BY LastModifiedDate DESC LIMIT 1];
    }

    public List<CaseComment> getSaaSlastCaseComment() {
        return cComment;
    }
}

 Here is my Visualforce Component:

<apex:component controller="findSaaSlastCaseComment" access="global">
    <apex:attribute name="caseId" description="Salesforce Id of the Case" type="Id" assignTo="{!caseId}" />
    <apex:dataTable value="{!SaaSlastCaseComment}" var="lastCaseComment">
        <apex:column >
            {!lastCaseComment.CommentBody}
        </apex:column>
    </apex:dataTable>
</apex:component>

 Here is an extract of my Email Template:

<messaging:emailTemplate recipientType="Contact"
    relatedToType="Case"
    subject="{!relatedTo.Subject}">
    <messaging:htmlEmailBody >
        <html><body>
	Dear customer...
        Description: {!relatedTo.Description}

        Last comment: <c:findSaaSlastCaseComment />

        </body></html>
    </messaging:htmlEmailBody>
<messaging:plainTextEmailBody >
	...
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 As I understand CaseId is empty because the mail template references the Id as "RelatedTo.CaseId" not "CaseId", but I don't know (I am not a developer) how to reference CaseId the right way.

 

Is there a better solution (unfortunately {!Case.Last_Case_Comment} is not available in Visualforce Email Template)?

 

Many thanks for your answers,

Yves

I would like to improve the Case Comment Template defined in our Cases / Support Settings.

It's a Visualforce Email Template, working well (including translations) but missing the "Last Case Comment" information.

 

I have tried a bunch of solution with no success until now. Can someone pinpoint what I am doing wrong ?

 

Here is my Apex Class:

public class findSaaSlastCaseComment {
    private final List<CaseComment> cComment;
    public Id caseId {get; set;}

    public findSaaSlastCaseComment() {
        cComment = [SELECT CommentBody FROM CaseComment WHERE ParentId = :caseId AND IsPublished = True ORDER BY LastModifiedDate DESC LIMIT 1];
    }

    public List<CaseComment> getSaaSlastCaseComment() {
        return cComment;
    }
}

 Here is my Visualforce Component:

<apex:component controller="findSaaSlastCaseComment" access="global">
    <apex:attribute name="caseId" description="Salesforce Id of the Case" type="Id" assignTo="{!caseId}" />
    <apex:dataTable value="{!SaaSlastCaseComment}" var="lastCaseComment">
        <apex:column >
            {!lastCaseComment.CommentBody}
        </apex:column>
    </apex:dataTable>
</apex:component>

 Here is an extract of my Email Template:

<messaging:emailTemplate recipientType="Contact"
    relatedToType="Case"
    subject="{!relatedTo.Subject}">
    <messaging:htmlEmailBody >
        <html><body>
	Dear customer...
        Description: {!relatedTo.Description}

        Last comment: <c:findSaaSlastCaseComment />

        </body></html>
    </messaging:htmlEmailBody>
<messaging:plainTextEmailBody >
	...
</messaging:plainTextEmailBody>
</messaging:emailTemplate>

 As I understand CaseId is empty because the mail template references the Id as "RelatedTo.CaseId" not "CaseId", but I don't know (I am not a developer) how to reference CaseId the right way.

 

Is there a better solution (unfortunately {!Case.Last_Case_Comment} is not available in Visualforce Email Template)?

 

Many thanks for your answers,

Yves