Last active
August 29, 2015 14:11
-
-
Save amonshiz/2cdd89ded3da2627f077 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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