Search code examples
c#asp.netwsdlsalesforcesalesforce-chatter

How to retrieve FeedComment using Chatter SalesForce WSDL service in C#


I have to retrieve News feed of salesforce chatter I am able to get main status but not able to retrieve comments. Is there any sample to get comments using SalesForce chatter WSDL API in c#?


Solution

  • You can use child relationship queries to traverse from the NewsFeed to the child FeedComments. Here's an example of a SOQL query that returns both the main status and comments for a given user:

    SELECT Id, Body, (Select Id, CommentBody FROM FeedComments) FROM NewsFeed WHERE ParentId = '00560000000wX0aAAE'
    

    Not sure about C# specifically, but it will likely return the FeedComments as a nested array. Here's an example of iterating over the results in Apex:

    NewsFeed nf = [SELECT Id, Body, (Select Id, CommentBody FROM FeedComments) FROM NewsFeed WHERE ParentId = '00560000000wX0aAAE'];
    
    System.debug(nf.Id);
    System.debug(nf.Body);
    for (FeedComment fc : nf.FeedComments) {
       System.debug(fc.Id);
       System.debug(fc.CommentBody);
    }