@Mention Chatter Users using Trigger

  1. For Apex class Click here
    Note: If you are installing into a sandbox organization you must replace the initial portion of the URL with http://test.salesforce.com
  2. set Up -> Security Controls -> remote Site settings and edit remote settings, change XXXX => na12/na11 , not sure where to get? check your browser for URL it may be like ap1, eu1 etc ![](/content/images/2014/Sep/Screen-Shot-2014-09-17-at-10-43-33-AM.png)
>Usage

feedMention.addMention(<Record Id>, <Chatter Text Post>, <User Id to @metnion>, <Session ID>);

Total four parameters to pass,

  1. Record Id => record which to want to post chatter post
  2. Chatter Text => Chatter Text which want to appear in chatter post
  3. User Id => User Id to @mention in chatter post
  4. session Id => userinfo.getSessionId() (this is default method to get session id suing Apex)

NOTE: you can use this in Before update, after Update, after Insert, Apex Classes also