Newer Version Available

This content describes an older version of this product. View Latest

FeedComment

Represents a comment added to a feed by a user. This object is available in API version 18.0 and later.

Supported Calls

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

Special Access Rules

Note the following when working with feed comments.

  • You must have read access to the feed’s parent type to see a FeedComment record.
  • You must have access to the feed to add a comment.
  • If the comment is related to a user record, the user can delete the comment. For example, if John Smith makes a comment about Sasha Jones, Sasha can delete the comment.
  • If the logged-in user has the “Insert System Field Values for Chatter Feeds” user permission, the create field property is available on CreatedBy and CreatedDate system fields. During migration, the logged-in user can set these fields to the original post’s author and creation date. The fields can’t be updated after migration.
You can delete all feed items you created. To delete feed items you didn’t create, you must have one of these permissions:
  • “Modify All Data”
  • “Modify All” on the object associated with the feed and delete permission on the parent feed
  • “Moderate Chatter”

    Users with the “Moderate Chatter” permission can delete only the feed items and comments they see.

    Note

  • “Manage Unlisted Groups”

    Only users with this permission can delete items in unlisted groups.

Fields

Field Details
CommentBody
Type
textarea
Properties
Create, Filter, Sort, Update
Description
The text in the comment.
CommentType
Type
reference
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
Before 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.
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 an application migrates posts and comments from another application into a feed, the InsertedBy value is set to the ID of the logged-in user.
LastEditById
Type
reference
Properties
Create, Filter, Group, Nillable, Sort
Description
ID of the user who last edited the feed comment.
LastEditDate
Type
datetime
Properties
Create, Filter, Nillable, Sort
Description
The date the feed comment was last edited.
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.

Revision
Type
int
Properties
Create, Filter, Group, Nillable, Sort
Description
The number of times the comment was revised.
SystemModstamp
Type
dateTime
Properties
Defaulted on create, Filter
Description
Date and time when a user or automated process (such as a trigger) last modified this record. SystemModstamp is a read-only system field, available in FeedComment as of API version 37.0.

Usage

  • As of API version 23.0 and later, if you have “View All Data” permission, you can query FeedComment records directly without an ID filter. If you don’t have “View All Data” permission, you can’t query FeedComment records directly, with or without an ID filter.

    For example, the following query returns general information about a feed:
    1SELECT ID, CreatedDate, CreatedById, CreatedBy.FirstName, 
    2           CreatedBy.LastName, ParentId, Parent.Name, Body 
    3FROM FeedItem 
    4WHERE CreatedDate > LAST_MONTH 
    5ORDER BY CreatedDate DESC, Id DESC
  • 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:
    1public void searchSample() {
    2  try {
    3    SearchResult sr = connection.search("find {foo} in all fields " +
    4        "returning feedcomment(Id, FeedItemId, CommentBody)");
    5    // Put the results into an array of SearchRecords
    6    SearchRecord[] records = sr.getSearchRecords();
    7    // Check the length of the returned array of records to see
    8    // if the search found anything
    9    if (records != null && records.length > 0) {
    10      System.out.println("Found " + records.length + " comments: ");
    11      // Display each comment
    12      for (SearchRecord record : records) {
    13        FeedComment comment = (FeedComment) record.getRecord();
    14        System.out.println(comment.getId() + ": " + 
    15            comment.getCommentBody());
    16      }
    17    } else {
    18      System.out.println("No records were found for the search.");
    19    }
    20  } catch (ConnectionException ce) {
    21    ce.printStackTrace();
    22  }
    23}
  • If you use an Apex trigger to modify the Body of a FeedComment object, all mentions hyperlinks are converted to plain text. The mentioned users don't get email notifications.

This object is hard deleted. It isn’t sent to the Recycle Bin.

Note