You can write triggers on the FeedItem and FeedComment triggers.
- Only FeedItems of Type
TextPost, LinkPost, HasLink, ContentPost, and HasContent can be inserted, and therefore invoke the before or after insert trigger. User status updates don't cause the FeedItem
triggers to fire.
- While FeedPost objects were supported for API versions 18.0,
19.0, and 20.0, don't use any insert or delete triggers saved against versions
before 21.0.
- For FeedItem the following fields are not available in the before insert trigger:
In addition, the ContentData field is not available in any delete trigger.
-
Triggers on FeedItem objects run before their attachment and capabilities information is
saved, which means that ConnectApi.FeedItem.attachment information and ConnectApi.FeedElement.capabilities
information may not be available in the trigger.
The attachment and capabilities information may not be available from these
methods: ConnectApi.ChatterFeeds.getFeedItem, ConnectApi.ChatterFeeds.getFeedElement,
ConnectApi.ChatterFeeds.getFeedPoll, ConnectApi.ChatterFeeds.getFeedElementPoll, ConnectApi.ChatterFeeds.postFeedItem,
ConnectApi.ChatterFeeds.postFeedElement, ConnectApi.ChatterFeeds.shareFeedItem,
ConnectApi.ChatterFeeds.shareFeedElement, ConnectApi.ChatterFeeds.voteOnFeedPoll,
and ConnectApi.ChatterFeeds.voteOnFeedElementPoll
- For FeedComment
before insert and after insert triggers, the fields of a ContentVersion associated with the FeedComment (obtained through FeedComment.RelatedRecordId) are not available.
-
Apex code uses
extra security when executing in a Chatter context.
To post to a private group, the user running the code must be a member of that
group. If the running user isn't a member, you can set the
CreatedById field to be a member of the group in the
FeedItem record.
Note the following for the
CollaborationGroup and
CollaborationGroupMember objects:
-
When CollaborationGroupMember is updated, CollaborationGroup is automatically updated as well to ensure that the member count is
correct. As a result, when CollaborationGroupMember
update or delete triggers run, CollaborationGroup
update triggers run as well.