Activity Forums Salesforce® Discussions Is it possible a multi-level relationship query on Chatter/Comments?

  • Nitish

    Member
    April 14, 2016 at 8:39 am

    Hi Himanshu,

    Yes, we can do that, Here is a sample code, please try this and let me know if it is helpful

    List<FeedItem> feedWithComments = [SELECT Id,Body,ParentId, (SELECT Id, CommentBody, FeedItemId FROM FeedComments) FROM FeedItem WHERE ParentId IN (SELECT Id FROM myObject WHERE Field = 'value')];

  • Ravi

    Member
    April 14, 2016 at 8:40 am

    Yes,It is possible a multi-level relationship query on Chatter/Comments? Separate the feed from the object to avoid a nested query.
    refer this link:http://salesforce.stackexchange.com/questions/4/how-to-do-a-multi-level-relationship-query-on-chatter-comments

  • Parul

    Member
    September 20, 2018 at 12:05 am

    Hi,

    You can use this query:-

    List<FeedItem> feedWithComments = [SELECT Id,Body,ParentId, (SELECT Id, CommentBody, FeedItemId                                                                                  FROM FeedComments)

    FROM FeedItem

    WHERE ParentId IN (SELECT Id FROM myObject WHERE Field =                                                                                  'value')];

  • shariq

    Member
    September 20, 2018 at 8:08 pm

    Hi,

    Try this -

    List<FeedItem> testfeed = [SELECT Id (SELECT
    Id, CommentBody, FeedItemId FROM FeedComments) FROM
    FeedItem WHERE ParentId IN (SELECT Id FROM
    sobject__c WHERE field__c = 'testvalue')];

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs