3

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.

3 Answers 3

2

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.

http://blogs.developerforce.com/developer-relations/2013/02/getting-started-with-connect-in-apex.html

2
  • 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, 2013 at 22:43
  • Nope, I've done it for a mention, should be alright. Apr 3, 2013 at 0:02
1

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.

1

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .