I have triggers on FeedItem and FeedComment where I need to dynamically read a field on their respective Parents (ParentId).

For FeedItem I can do (for example):


But for FeedComment, which seems analogous in most respects


does not work, and the Force.com IDE Schema doesn't seem to help me out. Is there no way of getting for example the FeedComment Account Name without an SOQL query?

  • 1
    Have you tried going through the feed item. FeedComment is a child of FeedItem, which is the child of the record in question. So shouldn't it be FeedComment.FeedItem.Parent.get()?
    – pchittum
    Commented Sep 2, 2013 at 23:42
  • FeedComment.FeedItem gives "Invalid foreign key relationship: FeedComment.FeedItem"
    – George S.
    Commented Sep 3, 2013 at 12:45

1 Answer 1


Of course, I found that to get the Parent info in a trigger context I had to use an SOQL query.

But then, I found that even


doesn't work, since it is a polymorphic field. See here for a description of the problem, and here for a potential solution in the future.

So, I use the method FeedComment.ParentId.getSobjecttype() to get the object to describe. A complication is that the field to dynamically get may or may not be present in the org, and so I have to query non-statically, and catch any QueryException caused by the field not being present. Not ideal, but it seems to work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .