10 votes

FeedItem Trigger - Parse Mentions?

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 @...
alouie's user avatar
  • 2,893
7 votes
Accepted

Query Chatter Feed, Topics, and Groups

Trusty old ChildRelationship to the rescue: for (ChildRelationship relation : SObjectType.Topic.getChildRelationships()) system.debug(relation); Relevant relationships and properties: [...
Adrian Larson's user avatar
  • 150k
7 votes
Accepted

What are the mandatory fields of FeedItem Object?

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 - ...
Samir's user avatar
  • 2,669
6 votes
Accepted

FeedItem Trigger - Parse Mentions?

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: ......
Adrian Larson's user avatar
  • 150k
6 votes
Accepted

Query FeedComments for specific parent Type

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 ...
Patlatus's user avatar
  • 16.7k
5 votes
Accepted

Apex - Accurately Identify users tagged in Chatter comments and set them as followers automatically

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 ...
Adrian Larson's user avatar
  • 150k
5 votes
Accepted

Posting Badge Information to Chatter

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 ...
user2582622's user avatar
4 votes
Accepted

Upload a file to a chatter feed in Apex: API 36

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 ...
Jason Hartfield's user avatar
4 votes
Accepted

How to insert FeedItem from Apex Email Service and set the Network ID?

Ok, figured it out thanks to Neil Hayek of Salesforce. Answer is super simple! Set the community id in the FeedItem.NetworkScope field. FeedItem fi = new FeedItem( parentId = 'chatter group id ...
Doug Ayers's user avatar
  • 4,186
4 votes
Accepted

How get FeedItem with type TrackedChange

The history tracking records are created asynchronously. You can confirm this behaviour by simply running the update on an account and comparing the created date time of tracked change with Account ...
manjit5190's user avatar
  • 8,023
3 votes
Accepted

Feed Item of type TrackedChange replies missing in query

The reply to the FeedTrackedChange is stored in a different sObject, a FeedComment. Both of these are children of a FeedItem (related to a specific sObject). Have a look at the ERD and I think it will ...
John Thompson's user avatar
3 votes

Createddate not showing as editable in UI

Some of the System fields are not editable. So in other words you can not modify createddate of record. This done by design and there are few exceptions for while performing data migration Salesforce ...
AtulRajguru9's user avatar
  • 9,120
3 votes
Accepted

How do I create a post to my Opportunity feed via REST API

You could use this endpoint url /services/data/v36.0/sobjects/FeedItem And use POST method and pass the body { "ParentId": "0069000000K8YjL", "Body" : "hello there", "type" : "TextPost", "Title" :...
Ratan Paul's user avatar
  • 22.7k
3 votes
Accepted

Parent id field of feed item object

When you have a reference of type ID (such as your FeedItem parent ID) you can directly get the type token of the object (in this case the parent object) and add whatever dependent logic you need: Id ...
Keith C's user avatar
  • 136k
3 votes

System.NullPointerException: Attempt to de-reference a null object(about feeditem object)

In your code you have a feed class-level property and also local variables with the same name of feed. The local variables "hide" the class level property: you assign a value in the methods to the ...
Keith C's user avatar
  • 136k
3 votes
Accepted

Email is not firing for feeditem records inserted through DataLoader

Referring to the Knowledge Article Chatter post does not trigger Chatter email notifications , it is the expected behavior not to trigger emails during data migration. This feature is available for ...
Jayant Das's user avatar
  • 30.6k
3 votes
Accepted

How can I mark 'Best Answer' through ConnectApi?

You need to use ConnectApi.QuestionAndAnswers.updateQuestionAndAnswers after this. https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/...
Sushil Bhardwaj's user avatar
3 votes

How to create a Case Feed Item when creating a Task

Based on my testing, the standard functionality of auto creating FeedItem on insert of Task; only works when TaskSubtype is set to Task or Call. I inserted 4 tasks based on the TaskSubtype values, ...
Raul's user avatar
  • 18.8k
2 votes
Accepted

How to get the body of Chatter Files in Apex?

As per the doc This field only Available in API version 35.0 and earlier only. Available in API version 35.0 and earlier only. This field is required if Type is ContentPost. Encoded file data ...
Ratan Paul's user avatar
  • 22.7k
2 votes
Accepted

Rest API FeedItem ContentData download

As per v36.0, FeedItem object was introduced with the changes: The following fields have been removed, and are available in API version 35.0 and earlier only . These fields are no longer in use ...
dmachop's user avatar
  • 1,089
2 votes
Accepted

Upload file linked with Opportunity record

So, thanks to @AntonioManente i was able to this with this piece of code: ContentVersion cont = new ContentVersion(); cont.Title = 'Title for this contentVersion'; cont.PathOnClient = 'file_' + ...
Martin.Kona's user avatar
2 votes
Accepted

Post chatter feed element from other chatter account

Currently, both Chatter in Apex and the Chatter REST API do not support impersonation like the SObject API does. You can only post feed items as the current, logged-in user. This is documented in "...
Benjamin Pirih's user avatar
2 votes
Accepted

Query feeditem object with InsertedById.name

This will work for you: relatedFeedItems = [select Body, CreatedDate, createdby.name, InsertedBy.name, SystemModstamp from FeedItem] ...
Mr.Frodo's user avatar
  • 5,804
2 votes

Get chatter feeds what a user follows

You can either find the records a user is following through EntitySubscription, or leverage the NewsFeed which will give you the same Feed Items as what you can find on the home tab.
Fabien Taillon's user avatar
2 votes

How to save chatter post image as attachment

The file is available in Content Version object in salesforce. You can trigger on the feed post. Write an after insert trigger on feed post to copy the file to attachment
Mohith Shrivastava's user avatar
2 votes

Retrieve UserId of @mention user from chatter post in Apex

Here is the update of the code for 2023, getFeedItem is no longer support in latest API version. String communityId = null; String feedItemId = 'YOUR_FEEDITEM_ID'; ConnectApi.FeedElement feedItem = ...
Petr Novotny's user avatar
2 votes

How to get Custom Object with related Item__Feed in SOQL

Try this SELECT Id, Name, (SELECT Id, Body from Test__Feed //Relationship name) FROM Test__c
Sakthivel N's user avatar
2 votes

how can I query FeedAttachment body by SOAP API 36

These are the following ways you can retrieve the attachment of feed items "SELECT Body, (SELECT RecordId, Title, Type, Value FROM FeedAttachments) FROM FeedItem WHERE Id = ..." Take RecordId from ...
Santanu Boral's user avatar
2 votes

Is it possible to restrict certain users from deleting note entries in the Feed section?

There may be a simpler method, but this is what I have for now. Write a trigger on FeedItem on before delete and stop selected users from deleting a note: trigger feedtrigger on FeedItem (before ...
Rao's user avatar
  • 16.7k
2 votes

Query FeedComments for specific parent Type

In addition to the answer already presented, you can't use LIKE operator on an id field, as mentioned in the docs The LIKE operator is supported for string fields only. Id is not a string ...
Mahmood's user avatar
  • 5,984

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