3

Hi I am new to Salesforce and am trying to learn my way through APEX.

I am trying now to display some chatter information for a custom object record in Visualforce. This page will end up in a force.com site.

Suppose I have a nested SOQL statement in my controller like the one below. How can I display this in VF? Especially How I can display what is returned by the inner queries to FeedTrackedChanges, FeedComments and FeedLikes?

Thank you!

 List<Custom_Object__Feed> myfeed = [SELECT Id, Type, 
                     CreatedById, CreatedBy.FirstName, CreatedBy.LastName,
                     ParentId, Parent.Name, 
                     Body, Title, LinkUrl, ContentData, ContentFileName,
                         (SELECT Id, FieldName, OldValue, NewValue 
                          FROM FeedTrackedChanges ORDER BY Id DESC), 
                         (SELECT Id, CommentBody, CreatedDate,
                          CreatedBy.FirstName, CreatedBy.LastName
                          FROM FeedComments ORDER BY CreatedDate LIMIT 10),
                         (SELECT CreatedBy.FirstName, CreatedBy.LastName
                          FROM FeedLikes)
                     FROM Custom_Object__Feed
                     WHERE ParentID = 'a16Z0000000RnS4IAK'
                     ORDER BY CreatedDate DESC, Id DESC
                     LIMIT 20];    
3

You can use nested apex:repeat tags to display the rows from the subquery

<apex:repeat value="{!myFeed}" var="myFeedVar" >

    <apex:repeat value="{!myFeedVar.FeedTrackedChanges}" var="trackedChangeVar" >
       <apex:outputField value="{!trackedChangeVar.FieldName}" />
       ....
    </apex:repeat>

</apex:repeat>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.