Newer Version Available

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

FeedItem

FeedItem represents an entry in the feed, such as changes in a record feed, including text posts, link posts, and content posts.

This object is available in API version 21.0 and later. This object replaces FeedPost.

Supported Calls

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

Special Access Rules

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”
  • “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.

Only users with the “Modify All Data” permission can delete a FeedItem of Type TrackedChange.

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. The logged-in user can set these fields to the original post author and creation date during migration. The fields can't be updated after migration.

Fields

Field Name Details
BestCommentId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
The Id of the comment marked as best answer on a question post.
Body
Type
textarea
Properties
Create, Nillable, Sort, Update
Description
The content of the FeedItem. Required when Type is TextPost. Optional when Type is ContentPost or LinkPost. This field is the message that appears in the feed.

See the IsRichText field for a list of HTML tags supported in the body of rich text posts.

Tip

CommentCount
Type
int
Properties
Filter, Group, Sort
Description
The number of FeedComments associated with this feed item.
ConnectionId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
When a PartnerNetworkConnection modifies a record that is tracked, the CreatedBy field contains the ID of the system administrator. The ConnectionId contains the ID of the PartnerNetworkConnection. Available if Salesforce to Salesforce is enabled for your organization.
ContentData
Type
base64
Properties
Create, Nillable
Description
The file uploaded to the feed. Required if Type is ContentPost. Encoded file data. Cannot be 0 bytes. Can be any format. Setting this field automatically sets Type to ContentPost.
ContentDescription
Type
textarea
Properties
Create, Nillable, Sort
Description
The description of the file specified in ContentData.
ContentFileName
Type
string
Properties
Create, Group, Nillable, Sort
Description
The file uploaded to the feed. Required if Type is ContentPost. The name of the file uploaded to the feed. Setting ContentFileName automatically sets Type to ContentPost.
ContentSize
Type
int
Properties
Group, Nillable, Sort
Description
Read only. Automatically determined during insert. The size of the file (in bytes) uploaded to the feed.
ContentType
Type
string
Properties
Group, Nillable, Sort
Description
Read only. Automatically determined during insert. The MIME type of the file uploaded to the feed.
FeedPostId
Type
reference
Properties
Filter, Group, Nillable, Sort
Description
This field was removed in API version 22.0, and is available in earlier versions for backward compatibility only.

ID of the associated FeedPost. A FeedPost represents the following types of changes in an FeedItem: changes to tracked fields, text posts, link posts, and content posts.

HasContent
Type
boolean
Properties
Defaulted on create, Filter, Group, Sort
Description
Indicates whether the feed item has content.
HasLink
Type
boolean
Properties
Defaulted on create, Filter, Group, Sort
Description
Indicates whether the feed item has a link attached.
InsertedById
Type
reference
Properties
Filter, Group, Nillable, 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.
IsDeleted
Type
boolean
Properties
Defaulted on create, Filter, Group, Sort
Description
Standard system field. Indicates whether the record has been moved to the Recycle Bin (true) or not (false).
IsRichText
Type
boolean
Properties
Create, Defaulted on create, Filter, Group, Sort, Update
Description
Indicates whether the feed item Body contains rich text. Set IsRichText to true if you post a rich text feed item via the SOAP API. Otherwise, the post is rendered as plain text.

Rich text supports the following HTML tags:

  • <p>

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

    Tip

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

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

In API version 35.0 and later, any special characters in rich text are replaced by escaped HTML. In API version 34.0 and prior, all rich text appears as a plain-text representation.

Note

LastEditById
Type
reference
Properties
Create, Filter, Group, Nillable, Sort
Description
ID of the user who last edited the feed item.
LastEditDate
Type
datetime
Properties
Create, Filter, Nillable, Sort
Description
The date the feed item was last edited.
LikeCount
Type
int
Properties
Filter, Group, Sort
Description
The number of FeedLikes associated with this feed item.
LinkUrl
Type
url
Properties
Create, Nillable, Sort
Description
The URL of a LinkPost.
NetworkScope
Type
picklist
Properties
Create, Filter, Group, Nillable, Sort
Description
Specifies whether this feed item is available in the default community, a specific community, or all communities. This field is available in API version 26.0 and later, if Salesforce Communities is enabled for your organization.
NetworkScope can have the following values:
  • NetworkId—The ID of the community in which the FeedItem is available. If left empty, the feed item is only available in the default community.
  • AllNetworks—The feed item is available in all communities.
Note the following exceptions for NetworkScope:
  • Only feed items with a Group or User parent can set a NetworkId or a null value for NetworkScope.
  • For feed items with a record parent, users can set NetworkScope only to AllNetworks.
  • You can’t filter a FeedItem on the NetworkScope field.
ParentId
Type
reference
Properties
Create, Filter, Group, Sort
Description
ID of the object type to which the FeedItem object is related. For example, set this field to a UserId to post to someone’s profile feed, or an AccountId to post to a specific account.
RelatedRecordId
Type
reference
Properties
Create, Group, Nillable, Sort
Description
ID of the ContentVersion object associated with a ContentPost. For Work.com thanks posts, it’s the ID of the WorkThanks object associated with a RypplePost. This field is typically null for all posts except ContentPost and RypplePost.

For example, set this field to an existing ContentVersion and post it to a feed as a FeedItem object of Type ContentPost.

Revision
Type
int
Properties
Create, Filter, Group, Nillable, Sort
Description
The revision number of the feed item.
Title
Type
string
Properties
Create, Group, Nillable, Sort, Update
Description
The title of the FeedItem. When the Type is LinkPost, the LinkUrl is the URL and this field is the link name. The Title field can be updated on posts of Type QuestionPost.
Type
Type
picklist
Properties
Create, Filter, Group, Nillable, Sort
Description
The type of FeedItem. Except for ContentPost, LinkPost, and TextPost, don’t create FeedItem types directly from the API.
  • ActivityEvent—indirectly generated event when a user or the API adds a Task associated with a feed-enabled parent record (excluding email tasks on cases). Also occurs when a user or the API adds or updates a Task or Event associated with a case record (excluding email and call logging).

    For a recurring Task with CaseFeed disabled, one event is generated for the series only. For a recurring Task with CaseFeed enabled, events are generated for the series and each occurrence.

  • AdvancedTextPost—created when a user posts a group announcement.
  • AnnouncementPost—Not used.
  • ApprovalPost—generated when a user submits an approval.
  • BasicTemplateFeedItem—Not used.
  • CanvasPost—a post made by a canvas app posted on a feed.
  • CollaborationGroupCreated—generated when a user creates a public group.
  • CollaborationGroupUnarchived—Not used.
  • ContentPost—a post with an attached file.
  • CreatedRecordEvent—generated when a user creates a record from the publisher.
  • DashboardComponentAlert—generated when a dashboard metric or gauge exceeds a user-defined threshold.
  • DashboardComponentSnapshot—created when a user posts a dashboard snapshot on a feed.
  • LinkPost—a post with an attached URL.
  • PollPost—a poll posted on a feed.
  • ProfileSkillPost—generated when a skill is added to a user’s Chatter profile.
  • QuestionPost—generated when a user posts a question.
  • ReplyPost—generated when Chatter Answers posts a reply.
  • RypplePost—generated when a user creates a Thanks badge in Work.com.
  • TextPost—a direct text entry on a feed.
  • TrackedChange—a change or group of changes to a tracked field.
  • UserStatus—automatically generated when a user adds a post. Deprecated.
The following values appear in the Type picklist for all feed objects but apply only to CaseFeed:
  • AttachArticleEvent—generated event when a user attaches an article to a case.
  • CallLogPost—generated event when a user logs a call for a case through the user interface. CTI calls also generate this event.
  • CaseCommentPost—generated event when a user adds a case comment for a case object.
  • ChangeStatusPost—generated event when a user changes the status of a case.
  • ChatTranscriptPost—generated event when Live Agent transcript is saved to a case.
  • EmailMessageEvent—generated event when an email related to a case object is sent or received.
  • FacebookPost—generated when a Facebook post is created from a case. Deprecated.
  • MilestoneEvent—generated when a case milestone is completed or reaches violation status.
  • SocialPost—generated when a social post is created from a case.

If you set Type to ContentPost, also specify ContentData and ContentFileName.

Note

Visibility
Type
picklist
Properties
Create, Filter, Group, Nillable, Sort, Update
Description
Specifies whether this feed item is available to all users or internal users only. This field is available in API version 26.0 and later, if Salesforce Communities is enabled for your organization.
Visibility can have the following values:
  • AllUsers—The feed item is available to all users who have permission to see the feed item.
  • InternalUsers—The feed item is available to internal users only.
Note the following exceptions for Visibility:
  • For record posts, Visibility is set to InternalUsers for all internal users by default.
  • External users can set Visibility only to AllUsers.
  • Visibility can be updated on record posts.
  • The Update property is supported only for feed items posted on records.

Usage

  • If you are using API version 23.0 or later and have “View All Data” permission, you can directly query for a FeedItem. The following example returns the 20 most recent feed items.
    1SELECT ID, CreatedDate, CreatedById, CreatedBy.FirstName, CreatedBy.LastName, ParentId, Parent.Name, Body,
    2 (SELECT ID, FieldName, OldValue, NewValue, FROM FeedTrackedChanges ORDER BY ID DESC) 
    3FROM FeedItem 
    4WHERE CreatedDate > LAST_MONTH 
    5ORDER BY CreatedDate DESC, Id DESC LIMIT 20;
  • If you are using an earlier API version than version 23.0, query FeedItem objects through a feed (such as AccountFeed or OpportunityFeed). The following example returns all feed items for a given account, ordered by date descending:
    1SELECT Id, Type, FeedItem.Body 
    2FROM AccountFeed 
    3WHERE ParentId = AccountId ORDER BY CreatedDate DESC

    Provide the ParentId for API version 22.0 and earlier.

    Note

  • A FeedItem of type UserStatus is automatically created when a user adds a post to update the status. You can’t explicitly create a FeedItem of type UserStatus.
  • The FeedItem object doesn’t support aggregate functions in queries.
  • 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. The logged-in user can set these fields to the original post author and creation date during migration. The fields can't be updated after migration.
  • The size limit for an attachment on a profile or news feed is 25 MB.
  • The size limit for an attachment on a record feed is 5 MB.
  • You can’t use the content fields to update or delete the content.
  • You can’t filter or update the content fields.
  • Deleting a FeedItem via the API also deletes the associated content. Likewise, undeleting a FeedItem restores associated content.

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

    Note

  • After uploading to a feed, it is possible for an attachment or document to be deleted, marked private, or hidden by sharing rules. In this case, all content fields in a FeedItem object appear as null in a SOQL query.
  • You can’t explicitly create or delete a FeedTrackedChange record.
  • If you insert a FeedItem or FeedComment of Type ContentPost on a User or Group to create a file, the NetworkScope field value of the FeedItem is passed to the file.
  • If you use an Apex trigger to modify the Body of a FeedItem object, all mentions hyperlinks are converted to plain text. The mentioned users don't get email notifications.
  • If you insert rich text into the feed item body, make sure that the case of the opening and closing HTML tags matches. For example, <b>This is bold text</B> generates an error.