I've been thinking about something: There is no field "OwnerId" on Chatter post, how then system define who is the owner of this post?
4 Answers
There is no owner for FeedItem
records. Several of the other answers here are mixing up some of the relevant fields:
CreatedById is the user that authored this post. This is probably the closest analog for 'Owner'. This field is writable at insert time, e.g. for use in data loads that copy chatter feeds.
InsertedById is the user that inserted this post into the system; generally the same as CreatedById but not always (e.g. in the case of a data load). This field is never writable.
ParentId is the object on which the post was made. This will always be a feed-enabled object, like User or Account. This field is writable at insert time.
As I understand, Chatter relies on the FeedItem object which was introduced in the Spring '11 (earlier, it was FeedPost). FeedItem houses data about a chatter post such as the title, body, and content.
Every chatter post creates a new record in FeedItem. This object has two user related Ids:
- ParentId – relates to the user, group or record that a particular post is related to. So, this will be set a UserId if a post is intended to one’s profile feed, or an AccountId if a post is targeted to that specific account.
- InsertedByID - ID of the user who added to the feed.
Reference: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_feeditem.htm
If you look at the class definition for Feed Element in the ConnectAPI, you can see the details of the Parent Actor object referred to by a-leaner. Depending on the what the parent is (group vs user for instance) and what type the Feed Element is (FeedItem vs Generic) will affect what concrete type of class the Parent Actor is - e.g. a user vs a group.
It's also worth noting that Chatter is designed to work in the context of the running user, so for the most part you can't set the createdby to be someone else. You can still do that via the FedItem object with Apex, but that is quite limited in its capabilities - but the ConnectAPI does not support 'impersonation...
I did a presentation on the ConnectAPI at DF14 which also covers some of this
InsertedById : ID of the user who added this object to the feed. For example, if a client application migrates multiple posts and comments from another application into a feed, then the InsertedBy value is set to the ID of the logged-in user.