+ Start a Discussion
TheresaAndersonTheresaAnderson 

Value nullis is being passed to Chatter Group post

For some reason, in my chatter post - the value nullis is passed through rather than the Account name from the record.  Any suggestions on why the Account name is not passing through to the Chatter Group?

 

trigger ChatterPostSURLStatus on Contract (after update) {
  List<CollaborationGroup> oG = [Select ID, Name from CollaborationGroup where Name = 'SURL Renewal'];
  for(Contract c: Trigger.new){
    
      Date mySURLDate = Date.Today();
      Date myActivatedDt = date.valueOf(c.ActivatedDate);
      if((c.RecordTypeId=='xxxxxxxxxxxxx' || c.RecordTypeId =='xxxxxxxxxxxxxxxxxxxxxxxx')
          && c.Status == 'Granted' && c.sys_post_granted_chatter__c == True){
          FeedPost sPost = new FeedPost();
          sPost.ParentId = oG[0].Id;
          sPost.Type = 'TextPost';
          sPost.Body = c.Account + ' is now supported on Warranty';
          insert sPost;
      }
     }
}

Best Answer chosen by Admin (Salesforce Developers) 
TheresaAndersonTheresaAnderson

Solved my own problem. 

 

Created a custom formula field pointing to the Account Name.  Hid the field from the layout.  Referenced the custom field in the trigger.

 

Code:

 

          sPost.Body = 'The Account ' +c.Client_Name__c + ' is now supported on SURL';

All Answers

TheresaAndersonTheresaAnderson

the "is" came from my text string.  So my real issue is the null  value posting to Chatter.

TheresaAndersonTheresaAnderson

Solved my own problem. 

 

Created a custom formula field pointing to the Account Name.  Hid the field from the layout.  Referenced the custom field in the trigger.

 

Code:

 

          sPost.Body = 'The Account ' +c.Client_Name__c + ' is now supported on SURL';

This was selected as the best answer