0

I created an apex trigger that posts a new feeditem to a user's feed every time the opportunity status gets changed to "Closed Won". It works fine except for the fact that the post title says "John Doe to Jane Doe". I only want "Jane Doe" to show up as im posting to her feed. Why is my name (John Doe) showing up in the post title? I'm the one who triggered it by closing the deal, but I only want the person's feed I'm posting to, to show up. Thoughts?

`FeedItem post = new FeedItem(); 
post.ParentId = '00760000005T5HG';
post.Body = 'Test.';
insert.post;`
3

Try setting the FeedItem CreatedById to the User you are trying to post the feed to. In your example

post.createdById = '00760000005T5HG';

4
  • I believe "audit fields" (Created By, Creation Date) are locked down in Chatter like in other areas of the application and you have to contact support to make them writeable? – eyescream Dec 4 '12 at 10:47
  • You are right, but I was able to use CreatedById when creating the feedItem. – logontokartik Dec 4 '12 at 10:58
  • Its looks like we can either use InsertedById or CreatedById on FeedItem and set it to UserId, would resolve your original issue. I would go with InsertedById. – logontokartik Dec 4 '12 at 11:00
  • @logontokartik post.createdById worked. It was exactly what I was looking for thanks! On a side note, I tried InsertedById, and it said that field is not writable. Thanks again everyone! – user988 Dec 4 '12 at 15:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.