Is it possible to auto append a tag/hashtag to a Chatter feed item via a trigger? If so, is the syntax simply to wrap the hashtag in square brackets immediately following the hashtag? I've noticed that when pasting @mentions and hashtags that the Publisher does not create the link, only when typing the @ symbol or # symbol does the Publisher then start the autocomplete sequence. Pasted text is usually unlinked, so I didn't know if this was even possible from a trigger.


Yes, you can use the 'new' Connect in Apex (ConnectApi.HashtagSegment), which allows you to post mentions, hashtags, et all, which were only possible via the REST API earlier.


|improve this answer|||||
  • Thanks for the response, I'm hoping it's not terribly difficult to throw my feedItem at the ConnectAPI helper class from a trigger. – greenstork Apr 2 '13 at 22:43
  • Nope, I've done it for a mention, should be alright. – techtrekker Apr 3 '13 at 0:02

I don't know what the exact syntax is for doing hashtags and mentions, but there's no reason why you shouldn't be able to modify the post content in a trigger.

Appending a hashtag would presumably be as simple as post.body += '#thetag' (but with the right fields and objects ;)). To get them as links there must be more markup involved, I'd look at the content of a feed item that has such a link, and then mimic that in your trigger.

|improve this answer|||||

Answering my own question but I found out from some folks at Salesforce that hashtags and links are parsed out of plain text. Posting mentions can only be done through Chatter REST API or Connect in Apex.

|improve this answer|||||

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.