I'm trying to write a trigger that awards badges to people and then posts them in a chatter post.
I've found this: https://help.salesforce.com/HTViewSolution?id=000199013&language=en_US
Which is very helpful, and gets me 90% of the way to where I need to be. It lets me create thanks, and badges and post then on FeedItems.
However, what it doesn't get me is the ability to do @mention calls within the body of the post.
I've been searching and searching over the past few hours, and it seems the only way to get @mentions in there is to use the ConnectApi.ChatterFeeds class (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_ConnectAPI_ChatterFeeds_static_methods.htm). This looked very promising, and it's not too hard to get a FeedItem with an @mention in the body.
But what appears to be missing is the ability to attach the badge using these classes.
I've been pouring over ConnectApi.FeedElementInput (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_connectapi_input_feed_element.htm), and it seems that the "capabilities" section is what I should be using.
However, none of the capabilities on the input side (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_connectapi_input_feed_element_capabilities.htm#apex_connectapi_input_feed_element_capabilitites) seem to be relevant to the assignment of work thanks and work badges.
When I use the connectApi to query an existing feed item, and export it to json, I get this in the capabilities section:
"enhancedLink":{
"description":"You are so great at this!",
"icon":{
"height":75,
"url":"myUrl",
"width":75
},
"linkRecordId":null,
"linkUrl":null,
"title":"Awesome Selling!"
}
Which is a reference to my badge. However, there is no "linkRecordId" set.
There is also no "enhancedLinkCapabilityInput" option when inputting FeedElements.
So I am somewhat at a loss, I'd like to be able to generate these badges, get then into posts, and do @mentions.