2

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#?

Brij
  • 6,086
  • 9
  • 41
  • 69

2 Answers2

3

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);
}
ryanbrainard
  • 5,918
  • 35
  • 41
  • I have already seen this, There is no FeedComment class in C#,... that's why I asked question? – Brij Aug 16 '11 at 05:15
  • 1
    Are you using the Enterprise or Partner WSDL? I just checked the Enterprise WSDL 22.0, and FeedComment is there (assuming you have Chatter enabled when it was exported). The Partner WSDL on the other hand would not have a concrete class and would be accesses dynamically. – ryanbrainard Aug 19 '11 at 08:03
  • I used Partner WSDL that's why class is not there. – Brij Sep 05 '11 at 04:56
  • You should also check out the Chatter REST API - http://wiki.developerforce.com/page/Chatter_API - this makes it much easier to work with Chatter. – metadaddy Nov 04 '11 at 04:44
2

This will get you NewsFeed + Comments + Likes:

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 NewsFeed
                             ORDER BY CreatedDate DESC, Id DESC
                             LIMIT 100
pdolinaj
  • 1,087
  • 13
  • 21