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 

Ideas Regarding Trigger

trigger feeditemnofication on FeedItem (after update,after insert) {
   for (feeditem F :

                feeditem EE = [Select body,parentid from feeditem where Id = :F.Id];  
                opportunity op=[select id,ownerid from opportunity where id=:EE.parentid] ;
                User U= [select id,Email,Name from user where id =:op.ownerid ];
                 Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                String[] toAddresses = new String[] {};                  
                mail.setSubject('Record Feed Notification to record  owner' );                
                mail.setPlainTextBody('Hello,' + '\n\n' +'Please consider the following feed'+' '+'\n\n'+'Subject :'+F.body );
                Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });


In this parentid will of any thing like accound id ,opportunity id,quote id,userid--- i need to send email to the record owner when feed is posted .how i can write the code as global way (or) we need to write it seperately (if account id,if oppid,if quoteid).it woud be great it would have some sample code.
Swati GSwati G

Check if you can use type of in query. You will have to get it enabled by contacting salesforce.

Cory CowgillCory Cowgill
You can use the Schema Describe Methods to get back Record ID Prefix information. 

With that information you can check the RecordID, and if it starts with the Prefix you can determine the type.

Here is a sample code for using this in some Apex:

You code will look similar to:
for(Schema.SObjectType objType : sobjects)
            objDescribe = objType.getDescribe();
            String sobjectPrefix = objDescribe.getKeyPrefix();
            if(id != null && sobjectPrefix != null && id.startsWith(sobjectPrefix))

Cory CowgillCory Cowgill
Note: My above information is a bit old (BEFORE they gave TYPE in SOQL). But it still works. You should try and use the SOQL Type if you can get it enabled and it works for your use case, etc.