You need to sign in to do that
Don't have an account?
VT-
Post feeditem to parent account
Hi,
I'm trying to write an Apex code which will create a chatter post on an account when someone post on an opportunity related to this account.
I'm not very experienced in Apex, this is where I am so far :
Could anyone give me a clue on what is going wrong ?
Thanks.
VT.
I'm trying to write an Apex code which will create a chatter post on an account when someone post on an opportunity related to this account.
I'm not very experienced in Apex, this is where I am so far :
trigger Post_to_parent on FeedItem (after insert) { for (feeditem f : trigger.new){ String ParentID = f.ParentId; if (ParentID.startsWith('006')){ List<Opportunity> lstOppts = [select AccountID from Opportunity where id=:f.parentid]; FeedItem item = new FeedItem( parentId = lstOppts[0].id, body = '<p>test clone</p>', isRichText = true); insert item; } } }It fails because it loops recursively. I don't understand why since it create a post only when the chatter post is related to an opportunity and the code itself create a chatter post related to an account.
Could anyone give me a clue on what is going wrong ?
Thanks.
VT.
All Answers
Try This :
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For SFDC Support: varaprasad4sfdc@gmail.com
Blog: http://salesforceprasad.blogspot.com/
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1