Skip to content

Instantly share code, notes, and snippets.

@amonshiz
Last active August 29, 2015 14:11
Show Gist options
  • Save amonshiz/2cdd89ded3da2627f077 to your computer and use it in GitHub Desktop.
Save amonshiz/2cdd89ded3da2627f077 to your computer and use it in GitHub Desktop.
<apex:page standardController="Account" extensions="AccountCaseCommentsExtension" showHeader="true" sidebar="true">
<apex:pageBlock>
<apex:pageBlockSection>
<apex:pageBlockTable value="{!account.Cases}" var="c">
<apex:column value="{!c.CaseNumber}" />
<apex:column value="{!c.Subject}" />
<apex:column value="{!caseToCaseComment[c.Id].CommentBody}" />
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
public with sharing class AccountCaseCommentsExtension {
public Map<Id, CaseComment> caseToCaseComment {get; set;}
public AccountCaseCommentsExtension(ApexPages.StandardController sc) {
Account act = (Account)sc.getRecord();
caseToCaseComment = new Map<Id, CaseComment>();
for (CaseComment cc : [SELECT Id, ParentId, CommentBody, CreatedDate
FROM CaseComment
WHERE ParentId IN (SELECT Id FROM Case WHERE AccountId = '001j000000BwRBl')
ORDER BY ParentId ASC, CreatedDate DESC]) {
if (!caseToCaseComment.containsKey(cc.ParentId)) {
caseToCaseComment.put(cc.ParentId, cc);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment