Newer Version Available
FeedItem
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:
Only users with this permission can delete items in unlisted groups.
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.
Fields
| Field Name | Details |
|---|---|
| BestCommentId |
|
| Body |
|
| CommentCount | |
| ConnectionId |
|
| ContentData |
|
| ContentDescription | |
| ContentFileName | |
| ContentSize |
|
| ContentType |
|
| FeedPostId |
|
| HasContent |
|
| HasFeedEntity | |
| HasLink |
|
| HasVerifiedComment |
|
| InsertedById |
|
| IsClosed |
|
| IsDeleted | |
| IsRichText |
|
| LastEditById |
|
| LastEditDate |
|
| LikeCount | |
| LinkUrl | |
| NetworkScope |
|
| ParentId | |
| RelatedRecordId |
|
| Revision |
|
| Status |
|
| Title | |
| Type |
|
| Visibility |
|
Usage
-
When a Feed Item’s IsClosed field is set to true, some actions are blocked and others are blocked to most users. This table sets out the actions that are blocked when a Feed Item is closed.
Action Availability on a Closed Conversation Add a comment Blocked Answer a question Blocked Vote on a poll Blocked Edit a feed item or its comments or answers Blocked to author; available to admins, moderators, and people with the Close Conversation Threads in Feeds permission Editing is blocked specifically for the feed item title, feed item body, and feed content body fields.
Edit a topic Available Delete a feed item or its comments or answers Blocked to author; available to admins, moderators, and people with the Close Conversation Threads in Feeds permission Publish a pending review comment (community moderation) Available to admins and moderators Like or unlike; upvote or downvote Available Select or remove a best answer Blocked to author; available to admins, moderators, and people with the Close Conversation Threads in Feeds permission Company verify; remove verification Available only to people with the Verify Answers to Chatter Questions permission Flag Available Share Available Bookmark Available Mute and unmute Available Escalate to case Available only to people permitted to escalate a feed item to a case - This Apex example shows how to add an attachment to a Lead using API version 36.0 and
later. First, post a feed
item.
1//create and insert post 2FeedItem post = new FeedItem(); 3post.Body = 'HelloThere'; 4post.ParentId = 'ID_OF_LEAD_ENTITY'; 5post.Title = 'FileName'; 6insert post;Then insert the attachment.1//create and associate a content attachment to the post 2FeedAttachment feedAttachment = new FeedAttachment(); 3feedAttachment.FeedEntityId = post.Id; 4feedAttachment.RecordId = 'ID_OF_CONTENT_VERSION'; 5feedAttachment.Title = 'FileName'; 6feedAttachment.Type = 'CONTENT'; 7insert feedAttachment; - 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 - 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 - 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. 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.
- 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.
- 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.
- Imagine that you insert a FeedItem or FeedComment of Type ContentPost on a User or Group to create a file. Then 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.
- To check file sharing with Apex triggers, write triggers on ContentDocumentLink instead of FeedItem. For a ContentDocumentLink trigger example, see ContentDocumentLink.
- In API version 36.0 and later, use FeedAttachment to attach one or more content items to a FeedItem. As a result of support for multiple attachments through FeedAttachment, all fields related to content attachments have been removed. These fields are: ContentData, ContentDescription, ContentFileName, ContentSize, and ContentType.