FeedComment

Represents a comment added to a feed by a user. A FeedComment is a child object of an associated UserProfileFeed, NewsFeed, or object feed, such as AccountFeed. A user can subscribe to a record so that changes to the record are displayed in the Chatter feed on the user's home page, which is a useful way to stay up-to-date with changes made to records in Salesforce. Feeds are available in API version 18.0 and later.

Supported Calls

create(), delete(), describeSObjects(), query(), retrieve(), search()

Special Access Rules

Note the following when working with feed comments:

You can delete a feed item only if you created it, or if you have the any of these permissions:
  • “Modify All Data”
  • “Modify All” on the object associated with the feed as well as delete permission on the parent feed
  • “Moderate Chatter”
    Note
    Because it does not include “View All Data”, users with the “Moderate Chatter” permission are able to delete only the feed items and comments they are able to see.

Fields

Field Details
CommentBody
Type
textarea
Properties
Create, Filter, Sort
Description
The text in the comment.
CommentType
Type
picklist
Properties
Create, Filter, Group, Nillable, Restricted picklist, Sort
Description
The type of comment:
  • ContentComment—an uploaded file on a comment
  • TextComment—a direct text entry on a comment
Prior to API version 24.0, a text entry was required on a comment. As of version 24.0, a text entry is optional if the CommentType is ContentComment—an uploaded file on a comment.
FeedItemId
Type
reference
Properties
Create, Filter, Group, Sort
Description
ID of the feed containing the comment.
InsertedById
Type
reference
Properties
Filter, Group, Sort
Description
ID of the user who added this object to the feed. For example, if a client application migrates multiple posts and comments from another application into a feed, then InsertedById is set to the ID of the logged-in user.
ParentId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
ID of a record associated with the feed comment. For example, if you are commenting on a change to a field on Account, ParentId is set to the account ID.
RelatedRecordId
Type
reference
Properties
Create, Group, Nillable, Sort
Description
ID of the ContentVersion object associated with a ContentComment. This field is null for all comments except ContentComment.

For example, set this field to an existing ContentVersion and post it to a comment as a FeedComment object of CommentTypeContentComment.

Usage

As of API version 23.0 and beyond, if you have “View All Data” permission you can query FeedComment records directly, without an ID filter. For example, the following query returns general information about a feed:
SELECT ID, CreatedDate, CreatedById, CreatedBy.FirstName, 
           CreatedBy.LastName, ParentId, Parent.Name, Body 
FROM FeedItem 
WHERE CreatedDate > LAST_MONTH 
ORDER BY CreatedDate DESC, Id DESC

Prior to API version 23.0, you couldn't query FeedComment records directly. You could only query them via the parent NewsFeed, UserProfileFeed, or entity feed, such as AccountFeed. For example, the following query returns information, including child FeedComment records:

SELECT ID, CreatedDate, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, ParentId, Parent.Name,
        (SELECT CommentBody, FeedItemId FROM FeedComments ORDER BY ID DESC)
      FROM NewsFeed
      ORDER BY CreatedDate DESC, ID DESC
      LIMIT 20

You can search for text in comments using SOSL. For example, the following Java class uses search() to find the string “foo” in any field of a record:

public void searchSample() {
  try {
    SearchResult sr = connection.search("find {foo} in all fields " +
        "returning feedcomment(Id, FeedItemId, CommentBody)");
    // Put the results into an array of SearchRecords
    SearchRecord[] records = sr.getSearchRecords();
    // Check the length of the returned array of records to see
    // if the search found anything
    if (records != null && records.length > 0) {
      System.out.println("Found " + records.length + " comments: ");
      // Display each comment
      for (SearchRecord record : records) {
        FeedComment comment = (FeedComment) record.getRecord();
        System.out.println(comment.getId() + ": " + 
            comment.getCommentBody());
      }
    } else {
      System.out.println("No records were found for the search.");
    }
  } catch (ConnectionException ce) {
    ce.printStackTrace();
  }
}
Note
This object is hard deleted. It isn’t sent to the Recycle Bin.
© Copyright 2000–2012 salesforce.com, inc. All rights reserved.
Various trademarks held by their respective owners.