Skip to main content
11 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,903
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,679
7 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
  • 17.4k
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
  • 151k
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
  • 151k
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
  • 151k
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

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,206
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,063
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
  • 137k
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
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.9k
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

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

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

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

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,976
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
Accepted

How to count Chatter posts in SOQL?

Unfortunately The FeedItem object doesn’t support aggregate functions in queries. Other way of doing above would be querrying for FeedItems into a collection and checking the size in apex. Make sure ...
Hemavantha Rajesh Varma Mudunu's user avatar
2 votes

How To stop feedItem for status field on Case?

These objects and fields are tracked by default: Account: Account Name, Account Owner Case: Case Owner, Priority, Status Chatter Group: Allow Customers, Description, Group Access, Information Body, ...
sanket kumar's user avatar
  • 15.5k
2 votes
Accepted

How to render one component after another

$A.createComponent is an asynchronous function. You cannot guarantee the order of execution when you put multiple calls in a row. Either use $A.createComponents to create both components at once: $A....
sfdcfox's user avatar
  • 500k
2 votes
Accepted

How to find FeedItem where a ContentDocument is the RelatedRecordId

Consider querying FeedAttachment, which represents an attachment to a FeedItem. Knowing that you already have the ContentDocumentId, you can build the query as follows : SELECT Id, RecordId, ...
Shamina's user avatar
  • 4,337
2 votes
Accepted

Setup ConnectApi.FeedElementPage with message mentions for Test (setTestGetFeedElementsFromFeed)

I found that you can retrieve your actor using ConnectApi.ChatterUsers.getUser(communityId, userId) so with that I can set the record reference like so: mention.record = (ConnectApi.ActorWithId) ...
Sadistik's user avatar
2 votes

How to notify users

Responding my own question: Bell notification with FeedItem is achievable and it should appear. However, if the same admin user that is creating the feedItem is the parentId too, no notification will ...
Gabriel Serrano Salas's user avatar
1 vote

trigger on case feedItem when a chatter post is going on case it also receive by case team members

It looks to me as though the problem is with this section of code: for(CaseTeamMember ctm : [select id,ParentId from CaseTeamMember ...
crmprogdev's user avatar
1 vote
Accepted

How to create a FeedItem that has mentions in it with SOAP API?

It doesn't appear to be possible to do anything other than a plain text FeedItem with the SOAP API. I tried the following directly POSTed to the SOAP API. <soapenv:Envelope xmlns:soapenv="http://...
Daniel Ballinger's user avatar
1 vote
Accepted

Email notification to all Opportunity Team Members

use this code, I have tested it and it is working fine in my org: trigger emailFollowers on FeedItem (after insert) { String OppKeyPrefix = Opportunity.sObjectType.getDescribe().getKeyPrefix(); ...
salesforce Developer's user avatar
1 vote
Accepted

Best way to upload Chatter file

If the file is uploaded to me then it is by default privately shared. You need to open up file access via sharing. Refer Who Can See My File?
Santanu Boral's user avatar

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