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(), getDeleted(), getUpdated(), query(), retrieve(), search(), update(), upsert()

Special Access Rules

Note the following when working with feed comments.

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”
    Note

    Note

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

  • “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.
HasEntityLinks
Type
boolean
Properties
Defaulted on create, Filter, Group, Sort
Description
Indicates whether the feed CommentBody includes at least one link to a record.
Note

Note

This field is available starting in API version 43.0.

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.
IsRichText
Type
boolean
Properties
Create, Defaulted on create, Filter, Group, Sort, Update
Description
Indicates whether the feed CommentBody contains rich text. Set IsRichText to true if you post a rich text feed comment using the SOAP API. Otherwise, the comment is rendered as plain text.

Rich text supports the following HTML tags:

  • <p>
    Tip

    Tip

    Though the <br> tag isn’t supported, you can use <p>&nbsp;</p> to create lines.

  • <b>
  • <code>
  • <i>
  • <u>
  • <s>
  • <ul>
  • <ol>
  • <li>
  • <img>

    The <img> tag is accessible only through the API and must reference files in Salesforce similar to this example: <img src="sfdc://069B0000000omjh"></img>

Note

Note

This attribute is available as of API version 38.0. In API version 38.0 and later, the system replaces special characters in rich text with escaped HTML. In API version 37.0 and prior, all rich text appears as a plain-text representation.

IsVerified
Type
boolean
Properties
Defaulted on create, Filter, Group, Sort
Description
Determines whether a comment on a question is marked as Company Verified.

This field is available in API version 41.0 and later.

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.
Status
Type
picklist
Properties
Create, Group, Nillable, Restricted picklist, Sort, Update
Description
Specifies whether this feed comment is published and visible to all who have access to the parent feed item. To make changes to a comment’s status, the comment’s parent feed item must be in a published state. This field is available in API version 38.0 and later.
Possible values are:
  • Published—The comment is visible to all who have access to the parent feed item.
  • PendingReview—The comment is visible to its author and to users who can see the parent feed item and have “ViewAllData” or “CanApproveFeedPostAndComment” permission. The comment can be deleted by its author and users who can see the comment and have "CanApproveFeedPostAndComment" or "ModifyAllData" permission. If the parent feed item is published, the comment can be edited by its author and users who can see the comment and have "CanApproveFeedPostAndComment" or "ModifyAllData" permission. Comment status can be changed from Published to PendingReview and from PendingReview to Published by users who have "CanApproveFeedPostAndComment" or "ModifyAllData" permission.
    Some actions are blocked when a feed comment is pending review:
    • Select as Best—When a feed comment that is marked as best answer becomes unpublished, it’s removed as the best answer. If the comment is published, its best answer status is not restored.
    • Like and unlike
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:
    SELECT ID, CreatedDate, CreatedById, CreatedBy.FirstName, 
               CreatedBy.LastName, ParentId, Parent.Name, Body 
    FROM FeedItem 
    WHERE CreatedDate > LAST_MONTH 
    ORDER 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:
    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();
      }
    }
    
  • 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.
Note

Note

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

See Also