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
finalistfinalist 

Invalid Type : FeedPost in a trigger

I am trying to insert a FeedPost on a Contact when I add a new related record, and I'm using the code from the Chatter Code Recipes to insert a FeedPost:

 

 

FeedPost fpost = new FeedPost();
fpost.ParentId = oId; //eg. Opportunity id, custom object id..
fpost.Body = post;
insert fpost;

 

 

I replaced oId with the associated Contact.Id, but the error is occurring on the previous line: Save error : Invalid type : FeedPost

 

This is my Chatter dev org, so I know it's enabled - is there something else that I need to add when I'm working from a trigger?

Best Answer chosen by Admin (Salesforce Developers) 
Ron WildRon Wild

That might be the API version on your trigger.  Try editing the metadata file for the trigger, changing the version to 18.0 and refreshing.

All Answers

Ron WildRon Wild

Check the type of user doing the action that invokes your trigger.  If it's a customer portal user or other user type that doesn't have access to chatter you will get that error.

 

 

finalistfinalist

I'm trying to invoke it through a trigger, so the user would be System Administrator, wouldn't it?  It isn't deployed yet, it's still in dev.

Ron WildRon Wild

Apparently it runs with Sys Admin permissions, but the FeedPost has to be assigned a CreatedById, which is the user who performed the original insert/update/etc.

 

See my related post here: http://community.salesforce.com/t5/Chatter-Development/Chatter-not-accessible-by-Customer-Portal-Users/td-p/186423

 

I haven't gotten a response to my posts yet to know if I'm forgetting a step, but it looks like this is a bug that would preclude using Chatter with authenticated Sites applications.

 

- RW

 

finalistfinalist

I'm still writing the code; it hasn't gotten to the point of being run yet.  It's not that the trigger is failing, I can't even save the file yet.  It seems like I'm missing an #include or something.

Ron WildRon Wild

That might be the API version on your trigger.  Try editing the metadata file for the trigger, changing the version to 18.0 and refreshing.

This was selected as the best answer
finalistfinalist

Resetting API Version FTW!!  Silly me for assuming that new development in a new org would be using the latest API.

 

Thanks, man! 

cloudcodercloudcoder

It will use the latest API if you are using the latest version of Eclipse (or create it via the Browser)