+ Start a Discussion
bentonbenton 

Trigger not firing

Im a Newbie!

I have a trigger that will insert a post into chatter from my objects "Follow_Up_Action" field. It works when I am in the object detail page but it will not always work on an VF page with an apex repeat list. It seems like it is random and will work sometimes and put all changed fields into the correct objects.T

 

 rigger Code:

trigger chatterFollowUP on Building__c (after update) {
     
     for (Building__c hr : [Select Id, Follow_Up_Action__c, Follow_Up_Date__c from Building__c where Id in: Trigger.New]) 
     {
        Building__c buildingOLD = trigger.old[0];
        Building__c buildingNEW = trigger.new[0];
        if(buildingNEW.Follow_Up_Action__c != buildingOLD.Follow_Up_Action__c)

{

        Id aid = hr.id;
         FeedItem post = new FeedItem();
         post.ParentId = aid2;
         post.Body = hr.Follow_Up_Action__c ; // test to show
         insert post;
           }
    }

}

Best Answer chosen by Admin (Salesforce Developers) 
bentonbenton

I scratched this and did an apex class that shceduled apex every month. Does what I need it to do.