I want to get the associated CaseComment's CommentBody for a list of cases.
String queryFields = 'Id, Subject, CaseComment.CommentBody';
List<Case> cases = Database.query('select '+ queryFields +' from Case');
for(Case c: cases){
System.debug(c.CaseComment.CommentBody);
}
but this doesn't work as there is no reference in Case
object for the CaseComment
. CaseComment
has the field parentId
which stores id of associated Case
. How can I get CaseComment
. I don't want to query the CaseComment
object for each case in a loop.