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 @...
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 - ...
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 ...
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:
[...
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:
......
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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/...
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, ...
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.
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 ...
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 ...
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
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 ...
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 = ...
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 ...
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, ...
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....
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, ...
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) ...
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 ...
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
...
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://...
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();
...
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?
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
feeditem × 200chatter × 94
apex × 55
trigger × 30
chatter-feed × 29
feedcomment × 16
community × 14
case × 14
chatter-feed-tracking × 13
soql × 12
casefeed × 11
attachment × 9
connect-api × 9
visualforce × 7
rest-api × 7
contentdocument × 6
lightning × 5
api × 5
chatter-groups × 5
email × 4
visual-workflow × 4
query × 4
customer-community × 4
files × 4
contentversion × 4