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

Trigger on FeedItem

hi , i have written a simple Trigger on FeedItem when i am Creating a new record on custom object,  a new Item feed been created :" admin created this case." and the Trigger i wrote is not fired , why ???

Thanks .

Shashikant SharmaShashikant Sharma

Fiest please check your trigger is active and if it is inactive please activate it. In case it is already active then could you please provide your trigger code so that I can look into.


yes the Trigger is active



trigger FeedItem_beforeInsert on FeedItem (before insert,after insert) {
	system.debug('duduav is pinting  FeedItem'); 
	for (FeedItem f:
        String parentId = f.parentId;
        //We compare the start of the 'parentID' field to the Opportunity key prefix to
        //restrict the trigger to act on posts made to the Opportunity object.
        system.debug('duduav is pinting  f.parentId'+f.parentId);
        system.debug('duduav is pinting  f.Body'+f.Body);
        system.debug('duduav is pinting  f'+f);


when i am adding a feed i can see its working 


but when i am creating a new  record a feed is created but the Trigger is not runing


Shashikant SharmaShashikant Sharma

Fiest of all i did not understand why you have used both before insert and , after insert here,


And also provide me the code where you are performing action to fire the trigger.


To know more about triggers :





I will try to explain ,


when I am creating a new record ,( manually ) a new feed is Created 

and in the feed its written   :   "  admin created this case "  and i want to catch this event

is it Possible ?