8

You can use the new Chatter API in Apex to do this. It's in developer preview currently and is on by default in all Developer Edition orgs. (Note: It went GA in Summer '13.) Here's an example of how to use it: String communityId = null; String feedItemId = 'YOUR_FEEDITEM_ID'; ConnectApi.FeedItem feedItem = ConnectApi.ChatterFeeds.getFeedItem(communityId, ...


7

Body - The content of the FeedItem. Required when Type is TextPost. Optional when Type is ContentPost or LinkPost. ContentData - This field is required if Type is ContentPost. ContentFileName - This field is required if Type is ContentPost Go through the below doc for detailed info - You can check for other details about the fields mentioned above and ...


6

Each Chatter FeedItem can only have one parent record - and if you'd like these FeedItems to show up in a record's chatter feed, e.g. using <chatter:feed entityId="{!recordId}"/>, then you'll have to have the record be the parent of the FeedItem. So, to be able to accomplish your intention - of having a record show up in both the Record's feed and a ...


6

Hashtags are parsed out of plain text, but you need to use the Connect (Chatter API) or REST API to post mentions. I've answered a similar question here, which might help. Copy the FeedBodyParser Utility Class from http://developer.force.com/cookbook/recipe/connect-in-apex-pilot Then to post a mention simply use ConnectApi.FeedItemInput feedItemInput = ...


6

The object that you are looking for is called EntitySubscription. From the documentation Represents a subscription for a user following a record or another user. A user can subscribe to a record or to another user. You can see the full documentation using the link below. https://www.salesforce.com/us/developer/docs/api/Content/...


6

You have somehow embed the binary data into the field. Here's one way: trigger Update_image on FeedItem (after insert) { id Travelid ; blob img; // Just binary data, thanks! List<Object__c> lst = new List<Object__c>(); For(FeedItem f : Trigger.new){ Travelid = f.parentid; img = f.ContentData; ...


5

You can write a trigger to do this by deleting this post .Trigger will be on FeedItem object with ParentId as the AccountId and Body equal to one you recieved . The psuedo code for the same will be as below trigger FeedItemLeadConvDelete on FeedItem(after insert){ List<FeedItem> lstfeedItem=new List<FeedItem>(); String keyPrefix; ...


5

Unfortunately you cannot edit FeedItem. You can't see the object itself, but you can manage settings related to Chatter such as triggers on FeedItem under Setup->Customize->Chatter. If you're interested in seeing the properties of FeedItem I suggest checking out workbench. The Standard and Custom Object section under Info is invaluable. https://workbench....


5

Chatter in apex (ConnectApi) was designed for this type of coding: ConnectApi.FeedType feedType = ConnectApi.FeedType.UserProfile; ConnectApi.FeedItemInput input = new ConnectApi.FeedItemInput(); ConnectApi.MessageBodyInput messageInput = new ConnectApi.MessageBodyInput(); ConnectApi.TextSegmentInput textSegment; ConnectApi.MentionSegmentInput ...


5

FeedItem is a generic object represents any feed, whereas something like TaskFeed or CaseFeed only applies to that particular object. The main reason for using an object-specific feed object is that the generic FeedItem needs a high level of permission to query: If you are using API version 23.0 or later and have “View All Data” permission, you can directly ...


5

Unfortunately the ConnectApi classes currently don't support posting as another user. See here: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_connectapi_differences.htm The FeedItem SObject API supports impersonation, but it doesn't support posting @-mentions. So it's currently not possible to make an @-mention as another ...


5

Trusty old ChildRelationship to the rescue: for (ChildRelationship relation : SObjectType.Topic.getChildRelationships()) system.debug(relation); Relevant relationships and properties: [getChildSObject=FeedComment;getField=ParentId;getRelationshipName=null;] [getChildSObject=FeedItem;getField=ParentId;getRelationshipName=null;] You should just be ...


5

So I'd love to see someone else find a better way to do it, but I have discovered one working option: serialization. When looking at a serialized FeedItem in my debug logs, I saw something like: ..."RawBody": "<p>Sample text... {@005000000000000AAA}</p>"... However, I wasn't able to acceess this data via normal means. When I look at the Body, ...


5

I suspect that Adrian's solution is the more performant one, but here's a solution that doesn't use the undocumented rawBody serialization trick. It uses the ConnectApi Apex namespace, because @mentions in Chatter are only supported in ConnectApi or the Chatter REST API. In your FeedItem trigger, re-fetch the feed items using ConnectApi.ChatterFeeds....


5

I'll just repost the code I used for a similar requirement, without including any of the additional commentary I wrote here. I can't really speak to how well the ConnectAPI approaches work nor their speed. But I know this approach works because I have implemented it in a live environment. public with sharing class FeedItemService { public static final ...


5

For everyone confused on how to post a Thanks on Chatter WITH the Badge Attachment -- all you need to do is set the Type to RypplePost on the FeedItem and automatically the chatter post will display the badge information.


4

The answer is pretty unbelievable, and almost certainly a Salesforce bug. This fails when run as a Standard Platform User: Id ii = UserInfo.getUserId(); List<FeedItem> fis = [Select Id from FeedItem i where i.Id = :ii]; But this works: Id ii = UserInfo.getUserId(); List<FeedItem> fis = [Select Id from FeedItem where Id = :ii]; A regular ...


4

//Adding a Link post FeedItem post = new FeedItem(); post.ParentId = oId; //eg. Opportunity id, custom object id.. post.Body = 'Enter post text here'; post.LinkUrl = 'http://www.someurl.com'; insert post; http://www.salesforce.com/us/developer/docs/api/Content/...


4

Yes, here's the syntax: #[multi-word topic]


4

Got it figured out, turns out you just use ContentVersion to upload a File: // ContentVersion is how you upload a file! ContentVersion version = new ContentVersion(); version.Title='Mah File'; version.PathOnClient = 'C:\\mahfile.txt'; version.VersionData = Blob.valueOf('DummyFile'); insert version; // After you insert the ...


4

Sometimes fields declared as Reference do not really work as references. In such cases you need to use some ugly workarounds like this one: SELECT Id, FeedItemId, ParentId, RelatedRecordId FROM FeedComment WHERE FeedItemId IN ( Select id from FeedItem WHERE Parent.Type = :mySObjectType )


3

Edit - the ConnectAPI can do that - it's not the easiest thing to work with - but if have a regular attachment , this would post that attachment as a Chatter file on an Account's Feed: Attachment attach = [Select Id, Body, Name, Description, ContentType FROM Attachment WHERE Id = 'XXX']; //I am querying here - but so long as you have it in a controller, ...


3

I suggest code like this: trigger MyTrigger on FeedItem (after insert) { List<Case> updates = new List<Case>(); for (FeedItem fi : Trigger.new) { if (fi.ParentId.getSObjectType() == Case.SObjectType) { updates.add(new Case( Id = fi.ParentId, ??? = fi.??? )); ...


3

Update this particular line with this public class MLPost { public static void MLPostCreate(List<FeedItem> posts) { And update your trigger trigger MLPostTrigger on FeedItem (before insert) { List<FeedItem> posts = Trigger.new; MLPost.MLPostCreate(posts); // or you could also use // MLPost.MLPostCreate(trigger.new); } ...


3

You may also want to take a look at the "Global Publisher Layout" and check what Quick Actions you have in the Publisher Layout. For example, if the "Post" action is included there and is the first one in the list, you should see the "Post" publisher in your Chatter page. You use that publisher to create a text feed item.


3

Likes on comments aren't supported in the sObject API. They're only supported in the Chatter REST API and through the ConnectApi methods in Apex. If you know the ID of the comment, you can retrieve the likes on that comment.


3

To add more mentions, simply create more ConnectApi.MentionSegmentInput objects and add them to the messageBodyInput.messageSegments list before you call ConnectApi.ChatterFeeds.postFeedElement(). I agree with cricketlang's ConnectApiHelper suggestion too!


3

I'm not sure I can help you fix your code, but maybe you'll be interested in this design pattern that accomplishes pretty much the same thing. I'm not sure who the original author is, but it's included in the MavensMate sublime text plugin as a class template. First, add this universal "TriggerHandler" utility class to your code base: //This is a utitliy ...


3

Thank you guys for your help.I was able to achieve something like this.Posting the answer as it might help others also. list<FeedItem> lstFeedItem = new list<FeedItem>(); for(account acc : trigger.new ){ if(acc.Tracking_Field__c != trigger.oldMap.get(acc.Id).Tracking_Field__c ){ FeedItem objFeedItem = new FeedItem(); ...


3

I have fixed this issue. I have passed Network scope id. feed.ParentId = ''; // Community's Chatter Group ID feed.NetworkScope= ''; // ID of community (network)


Only top voted, non community-wiki answers of a minimum length are eligible