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
lujandlujand 

Need to be able to add comments to different post/topic of an Opportunity via Chatter REST API

Hi,

 

Here is my scenario.  Let says that I have 2 different posts (i.e., 1: Issues, 2: Resources) posted on an Opportunity.  Base on certain criteria/keywords,a new comment (textpost) via API needs to be under the first post.  In this case, I already know opportunity id (parentid) but I can't query on body field.  How can I retrieve a correct feed id? Is it something that can be done if I don't want to keep track of all feed id & topic pairs of each opportunity?

 

Thanks for all the helps.

 

Best Answer chosen by Admin (Salesforce Developers) 
ChrisOctagonChrisOctagon

One way to easily re-find a feed item might be to include a unique hashtag in it integrating the ID, such as #opp040302030403

All Answers

ChrisOctagonChrisOctagon

A GET on the /chatter/feed-items endpoint can take a "q" parameter for a query on the feed item body. It's documented here: http://www.salesforce.com/us/developer/docs/chatterapi/Content/connect_resources_feed-items_FeedItemsQuery.htm Unfortunately this doesn't quite fit your scenario because you can't restrict the query results to a specific parent ID. Maybe you could try doing a SOQL query over the regular REST API in order to get the feed item id you're looking for here.

 

ChrisOctagonChrisOctagon

Another alternative would be to make your comment using the SObject api from within an Apex trigger so that it is added when the post is added.

lujandlujand

Thanks for your reply, ChrisOctagon.  Comments are not added right the way after the post is added.  They are added when opportunity gets updated later on. 

ChrisOctagonChrisOctagon

One way to easily re-find a feed item might be to include a unique hashtag in it integrating the ID, such as #opp040302030403

This was selected as the best answer
lujandlujand

Thanks ChrisOctagon.