I'm trying to get a collection of chatter questions and their related replies, but for some reason, I'm getting the correct replies, but null values for the question object. Here's my code:

public List<WrapperQuestions> wrapperQuestions      { get; set; }
public List<Question> questionsList                 { get; set; }

public List<Question> getQuestions() {
        if(questionsList == null) {
            questionsList = new List<Question>();
            for(Question q: [SELECT q.Id, q.CreatorSmallPhotoUrl, q.CreatorName, q.CreatedDate, q.CreatedById, q.Body FROM Question q]) {
                // As each contact is processed we create a new WrapperQuestions object and add it to the contactList
        return questionsList;

    public class WrapperQuestions   // wrapper class to handle multiple objects.
        public List<Question> questions              { get; set; }
        public List<Reply> replies            { get; set; }

        public WrapperQuestions(List<Question> question)
             question = questions;
             //replies = replies;
             replies = [SELECT CreatedDate, CreatedById, QuestionId, Body, UpVotes, DownVotes FROM Reply];
  • Hey, thanks for posting separately from the other one. Can you post your actual code w/ FeedItem etc? – Brian Mansfield Aug 13 '15 at 20:30
  • No problem. This is my my actual apex code. I didn't use the FeedItem for this. – slim Aug 13 '15 at 20:32
  • Huh - does this even compile? Since when are Question and Reply standard SObjects... – Brian Mansfield Aug 13 '15 at 20:35
  • Not sure if they're standard SObjects, but I see them in the schema and I'm able to do a SOQL query to retrieve values: – slim Aug 14 '15 at 13:02
  • Select q.IsDeleted, q.Id, q.CreatorSmallPhotoUrl, q.CreatorName, q.CreatedDate, q.Body, (Select Name, CreatedDate, CreatedById, QuestionId, Body, UpVotes, DownVotes, CreatorName From Replies) From Question q – slim Aug 14 '15 at 13:08

Your Answer

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

Browse other questions tagged or ask your own question.