function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Amanda Byrne- Carolina Tiger RescueAmanda Byrne- Carolina Tiger Rescue 

apex code for Custom Object Chatter Feed

trying to modify a test trigger for the Chat Up app as advised in the documentation, and I'm not sure how I should change some of the code to reference a custom object instead of Account.

 

The sample code is:

 test.startTest();
        insert myOpportunities;
        test.stopTest();
        
        /*there should be 100 posts as you iterated 100 times*/
        List<AccountFeed> chatterPosts = [select id from AccountFeed where parentId = :a.id];
        System.assertEquals(chatterPosts.size(), 100);

 So I modified "AccountFeed" to my custom object "npe03__Recurring_Donation__c"

         test.startTest();
        insert myOpportunities;
        test.stopTest();
        
        /*there should be 100 posts as you iterated 100 times*/
        List<npe03__Recurring_Donation__cFeed> chatterPosts = [select id from npe03__Recurring_Donation__cFeed where parentId = :a.id];
        System.assertEquals(chatterPosts.size(), 100);

 

and I get this error:

Error: Compile Error: sObject type 'Recurring_Donation__cFeed' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names. at line 26 column 56

 

I've enabled Feed Tracking on the Recurring_Donation__c object (although I haven't selected any other fields to track.  Clearly it's not as simple as replacing "Account" with "npe03__Recurring_Donation__c"

 

How to fix?

 

Thanks, Amanda

Best Answer chosen by Admin (Salesforce Developers) 
Sean TanSean Tan

When a custom object has a feed it will not include the __c suffix, rather it will become __Feed. Try replacing these:

 

Recurring_Donation__cFeed

 

With:

 

Recurring_Donation__Feed

All Answers

Sean TanSean Tan

When a custom object has a feed it will not include the __c suffix, rather it will become __Feed. Try replacing these:

 

Recurring_Donation__cFeed

 

With:

 

Recurring_Donation__Feed

This was selected as the best answer
Amanda Byrne- Carolina Tiger RescueAmanda Byrne- Carolina Tiger Rescue
Thanks Sean, this was the right solution. The test now saves appropriately and I'm on to the next issue with getting it to work. :)

~ Amanda
Jaweed BashaJaweed Basha
Hi Sean,

I need your help in creating Chatter Feed Tracking through Apex Trigger.
I have a Custom Object with 8 Related List Objects. Whenever a related object record is created or deleted a chatter post need to shown.
I tried this in Standard way using Feed Tracking but it only creates chatter post when a record is created. Its not working when the record is deleted. I need to show the chatter feed even for the deletion Example( Test123- Jaweed deleted a capture team).

Thanks,
Jaweed